コード例 #1
0
 public string Sununits(Scaler scaler)
 {
     Console.WriteLine("Is your size in inches or centimeters? ");
     units = Console.ReadLine();
     if (units == "inches" || units == "in")
     {
         Console.WriteLine("If the Sun is " + size + " inches, then...");
         sizeCalc.FindPlanetSizesinInches(scaler);
         Console.WriteLine(" ");
         distCalc.FindDistancesinFeet(scaler);
         Console.ReadLine();
     }
     else if (units == "centimeters" || units == "cm")
     {
         Console.WriteLine("If the Sun is " + size + " centimeters, then...");
         sizeCalc.FindPlanetSizesinCentimeters(scaler);
         Console.WriteLine(" ");
         distCalc.FindDistancesinMeters(scaler);
         Console.ReadLine();
     }
     else
     {
         Console.WriteLine("Please type in valid units for computation");
         Console.ReadLine();
     }
     return(units);
 }
コード例 #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to Solar System Scaler. Here you can build your own scale model of Our Solar System. Just put in the size you want the Sun to be and the code does the rest. Give it a try!");
            Console.ReadLine();
            Scaler scaler = new Scaler();

            scaler.Sunsize();
            scaler.Sununits(scaler);
            scaler.ConvertUnits(scaler);
        }
コード例 #3
0
 public void Convertunits(Scaler scaler)
 {
     if (scaler.units.Equals("inches") || scaler.units.Equals("in"))
     {
         double rescaledSunSize = scaler.size * 2.54;
         Console.WriteLine("If the Sun is " + Math.Round(rescaledSunSize, 3) + " centimeters across, then...");
         double mercincm = mercSize * 2.54;
         Console.WriteLine("Mercury would be " + Math.Round(mercincm, 3) + " centimeters across.");
         double venincm = venSize * 2.54;
         Console.WriteLine("Venus would be " + Math.Round(venincm, 3) + " centimeters across.");
         double ertincm = ertSize * 2.54;
         Console.WriteLine("Earth would be " + Math.Round(ertincm, 3) + " centimeters across.");
         double marsincm = marSize * 2.54;
         Console.WriteLine("Mars would be " + Math.Round(marsincm, 3) + " centimeters across.");
         double jupincm = jupsize * 2.54;
         Console.WriteLine("Jupiter would be " + Math.Round(jupincm, 3) + " centimeters across.");
         double satincm = satSize * 2.54;
         Console.WriteLine("Saturn would be " + Math.Round(satincm, 3) + " centimeters across.");
         double urancm = uranSize * 2.54;
         Console.WriteLine("Uranus would be " + Math.Round(urancm, 3) + " centimeters across.");
         double neptincm = neptSize * 2.54;
         Console.WriteLine("Neptune would be " + Math.Round(neptincm, 3) + " centimeters across.");
     }
     else if (scaler.units.Equals("centimeters") || scaler.units.Equals("cm"))
     {
         double rescaledSunSize = scaler.size * 0.3937;
         Console.WriteLine("If the Sun is " + Math.Round(rescaledSunSize, 3) + " inches across, then...");
         double inchMercury = mercSize * 0.3937;
         Console.WriteLine("Mercury would be " + Math.Round(inchMercury, 3) + " inches across.");
         double Venusinches = venSize * 0.3937;
         Console.WriteLine("Venus would be " + Math.Round(Venusinches, 3) + " inches across.");
         double Earthinches = ertSize * 0.3937;
         Console.WriteLine("Earth would be " + Math.Round(Earthinches, 3) + " inches across.");
         double inchMars = marSize * 0.3937;
         Console.WriteLine("Mars would be " + Math.Round(inchMars, 3) + " inches across.");
         double inchjup = jupsize * 0.3937;
         Console.WriteLine("Jupiter would be " + Math.Round(inchjup, 3) + " inches across.");
         double satinch = satSize * 0.3937;
         Console.WriteLine("Saturn would be " + Math.Round(satinch, 3) + " inches across.");
         double uraninch = uranSize * 0.3937;
         Console.WriteLine("Uranus would be " + Math.Round(uraninch, 3) + " inches across.");
         double neptinch = neptSize * 0.3937;
         Console.WriteLine("Neptune would be " + Math.Round(neptinch, 3) + " inches across.");
     }
 }
コード例 #4
0
 public void FindPlanetSizesinCentimeters(Scaler scaler)
 {
     mercSize = ((scaler.size) / actualSunSize) * 4879;
     Console.WriteLine("Mercury would be " + Math.Round(mercSize, 3) + " centimeters across.");
     venSize = ((scaler.size) / actualSunSize) * 12104;
     Console.WriteLine("Venus would be " + Math.Round(venSize, 3) + " centimeters across.");
     ertSize = ((scaler.size) / actualSunSize) * 12742;
     Console.WriteLine("Earth would be " + Math.Round(ertSize, 3) + " centimeters across.");
     marSize = ((scaler.size) / actualSunSize) * 6779;
     Console.WriteLine("Mars would be " + Math.Round(marSize, 3) + " centimeters across.");
     jupsize = ((scaler.size) / actualSunSize) * 139822;
     Console.WriteLine("Jupiter would be " + Math.Round(jupsize, 3) + " centimeters across.");
     satSize = ((scaler.size) / actualSunSize) * 116464;
     Console.WriteLine("Saturn would be " + Math.Round(satSize, 3) + " centimeters across.");
     uranSize = ((scaler.size) / actualSunSize) * 50724;
     Console.WriteLine("Uranus would be " + Math.Round(uranSize, 3) + " centimeters across.");
     neptSize = ((scaler.size) / actualSunSize) * 49244;
     Console.WriteLine("Neptune would be " + Math.Round(neptSize, 3) + " centimeters across.");
 }
コード例 #5
0
 public void Convertunits(Scaler scaler)
 {
     if (scaler.units.Equals("inches") || scaler.units.Equals("in"))
     {
         double mercmeter = mercDistance * 0.3048;
         Console.WriteLine("Mercury would be " + Math.Round(mercmeter, 3) + " meters from the Sun.");
         double venmeter = venDistance * 0.3048;
         Console.WriteLine("Venus would be " + Math.Round(venmeter, 3) + " meters from the Sun.");
         double ertmeter = ertDistance * 0.3048;
         Console.WriteLine("Earth would be " + Math.Round(ertmeter, 3) + " meters from the Sun.");
         double marsmeter = marsDistance * 0.3048;
         Console.WriteLine("Mars would be " + Math.Round(marsmeter, 3) + " meters from the Sun.");
         double jupmeter = jupDistance * 0.3048;
         Console.WriteLine("Jupiter would be " + Math.Round(jupmeter, 3) + " meters from the Sun.");
         double satmeter = satDistance * 0.3048;
         Console.WriteLine("Saturn would be " + Math.Round(satmeter, 3) + " meters from the Sun.");
         double urameter = uraDistance * 0.3048;
         Console.WriteLine("Uranus would be " + Math.Round(urameter, 3) + " meters from the Sun.");
         double neptmeter = neptDistance * 0.3048;
         Console.WriteLine("Neptune would be " + Math.Round(neptmeter, 3) + " meters from the Sun.");
     }
     else if (scaler.units.Equals("centimeters") || scaler.units.Equals("cm"))
     {
         double mercfeet = mercDistance * 3.28084;
         Console.WriteLine("Mercury would be " + Math.Round(mercfeet, 3) + " feet from the Sun.");
         double feetVenus = venDistance * 3.28084;
         Console.WriteLine("Venus would be " + Math.Round(feetVenus, 3) + " feet from the Sun.");
         double Earthfoot = ertDistance * 3.28084;
         Console.WriteLine("Earth would be " + Math.Round(Earthfoot, 3) + " feet from the Sun.");
         double marfoot = marsDistance * 3.28084;
         Console.WriteLine("Mars would be " + Math.Round(marfoot, 3) + " feet from the Sun.");
         double jupfeet = jupDistance * 3.28084;
         Console.WriteLine("Jupiter would be " + Math.Round(jupfeet, 3) + " feet from the Sun.");
         double satfeet = satDistance * 3.28084;
         Console.WriteLine("Saturn would be " + Math.Round(satfeet, 3) + " feet from the Sun.");
         double urafeet = uraDistance * 3.28084;
         Console.WriteLine("Uranus would be " + Math.Round(urafeet, 3) + " feet from the Sun.");
         double footnept = neptDistance * 3.28084;
         Console.WriteLine("Neptune would be " + Math.Round(footnept, 3) + " feet from the Sun.");
     }
 }
コード例 #6
0
        public void FindDistancesinMeters(Scaler scaler)
        {
            double sunInMeters = (scaler.size) / 100;

            mercDistance = (sunInMeters / sizecalc.actualSunSize) * 57910000;
            Console.WriteLine("Mercury would be " + Math.Round(mercDistance, 3) + " meters away from the Sun");
            venDistance = (sunInMeters / sizecalc.actualSunSize) * 108200000;
            Console.WriteLine("Venus would be " + Math.Round(venDistance, 3) + " meters away from the Sun");
            ertDistance = (sunInMeters / sizecalc.actualSunSize) * 149600000;
            Console.WriteLine("Earth would be " + Math.Round(ertDistance, 3) + " meters away from the Sun");
            marsDistance = (sunInMeters / sizecalc.actualSunSize) * 227900000;
            Console.WriteLine("Mars would be " + Math.Round(marsDistance, 3) + " meters away from the Sun");
            jupDistance = (sunInMeters / sizecalc.actualSunSize) * 778200000;
            Console.WriteLine("Jupiter would be " + Math.Round(jupDistance, 3) + " meters away from the Sun");
            satDistance = (sunInMeters / sizecalc.actualSunSize) * 1427000000;
            Console.WriteLine("Saturn would be " + Math.Round(satDistance, 3) + " meters away from the Sun");
            uraDistance = (sunInMeters / sizecalc.actualSunSize) * 2870000000;
            Console.WriteLine("Uranus would be " + Math.Round(uraDistance, 3) + " meters away from the Sun");
            neptDistance = (sunInMeters / sizecalc.actualSunSize) * 4497000000;
            Console.WriteLine("Neptune would be " + Math.Round(neptDistance, 3) + " meters away from the Sun");
        }
コード例 #7
0
        public void ConvertUnits(Scaler scaler)
        {
            Console.WriteLine("Would you like to do a unit conversion?");
            string response = Console.ReadLine();

            if (response.Equals("Yes") || response.Equals("yes"))
            {
                sizeCalc.Convertunits(scaler);
                Console.WriteLine(" ");
                distCalc.Convertunits(scaler);
                Console.ReadLine();
            }
            else if (response.Equals("No") || response.Equals("no"))
            {
                Console.WriteLine("All right.");
            }
            else
            {
                Console.WriteLine("Invalid Response. Type Yes or No.");
                scaler.ConvertUnits(scaler);
            }
        }