1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
| namespace ConsoleAstr
{
class AstrCalc
{
public double ua =149598000;
protected double distTL = 384403;
protected double distTS = 194000000;
// light speed m/s
protected double ls = 299792458;
static void Main(string[] args)
{
AstrCalc a1 = new AstrCalc();
a1.displayDist();
a1.convertUA(a1.ua);
}
double displayDist()
{
//afficher les distances
int dist = 0;
Console.WriteLine("Entrer les distances voulues: 1 TerreLune, 2 Terre Soleil");
try
{
dist = int.Parse(Console.ReadLine());
switch (dist)
{
case 1: Console.WriteLine(this.distTL);
convertUA(this.distTL);
break;
case 2: Console.WriteLine(this.distTS); convertUA(this.distTS);
lightsTo(this.distTS);
break;
}
}
catch (FormatException e)
{
Console.WriteLine("erreur entrée");
displayDist();
}
catch (Exception e)
{
}
return 0;
} double convertUA(double v)
{
//UA = Unité Astronomique
try
{
Console.WriteLine("valeur de l'unite astro (km)", + this.ua);
Console.WriteLine("distance en km", +v);
double valueconv = v / ua;
Console.WriteLine("Distance en Unités Astronomiques", +valueconv);
return 0;
}
catch (DivideByZeroException e)
{
Console.WriteLine("Erreur: division par 0");
}
catch (ArithmeticException e)
{
Console.WriteLine("autre erreur arithmétique");
}
return 0;
}
double lightsTo(double distSol)
{
double tspeed = distSol / ls;
Console.WriteLine("temps mis par la lumiere pour arriver jusqu'à:", +tspeed);
return tspeed;
}
}
} |
Partager