Question

In: Computer Science

Create an enumeration named Planet that holds the names for the eight planets in our solar...

Create an enumeration named Planet that holds the names for the eight planets in our solar system, starting with MERCURY equal to 1 and ending with NEPTUNE.

Write a program named Planets that prompts the user for a numeric position, and display the name of the planet that is in the requested position.

For example, if 3 is input, the output would be: EARTH is 3 planet(s) from the sun

Answer in C#

(Posting incomplete and probably wrong code that i have so far for this attempt. any help is appreciated.)

using System;
using static System.Console;
class Planets
{
{

enum Planets { Mercury, Venus, Earth, Mars, Jupiter, Saturn, Neptune, Uranus };
static void Main(string[] args)
{
WriteLine("Enter position for the planet: \n");
string input = ReadLine();
int number; Int32.TryParse(input, out number);
Planets planet = (Planets)1;
WriteLine("The planet is " + planet);
}
}
}

Solutions

Expert Solution

using System;

class Planet
{
    enum Planets { Mercury = 1, Venus, Earth, Mars, Jupiter, Saturn, Neptune, Uranus }; // here we set index
    static void Main(string[] args)
    {
        Console.Write("Enter position for the planet: ");
        string input = Console.ReadLine();
        int num = Convert.ToInt32(input); // convert to int and save in num
        Console.WriteLine(Enum.GetName(typeof(Planets), num)+" is " + input + " planet(s) from the sun" );
        Console.Read(); // TO STOP CONSOLE
    }
}

/* OUTPUT */


Related Solutions

2. There are 8 confirmed planets in our solar system. The number of significant figures in...
2. There are 8 confirmed planets in our solar system. The number of significant figures in this number is 1. True or False? Explain. 3 Do the following calculations, reporting the correct number of significant figures in your answer. a) 6.53x10^3g/12.8mL b) 5.621mL+ 22.4mL+5mL c) 3.3mm x 23.4mm x 1.769mm d) (965.43 x 3.911)+ 9413.4136 4. Preform the following conversions, reporting the correct number of significant figures in your answers. a) 1.976 x 10^-3 g to micro g b) 1.25...
At what orbital radius would a planet in our solar system have to be to enjoy...
At what orbital radius would a planet in our solar system have to be to enjoy “Earth-like” temperatures and conditions when the Sun arrives at the tip of its Red Giant “branch” (about 5 billion years hence). Compare your answer to the present orbital radius of Pluto. Assume that the orbit of earth is circular around the sun.
1. About 1 in 5 solar systems outside of our solar system has an Earth-sized planet...
1. About 1 in 5 solar systems outside of our solar system has an Earth-sized planet that could support life as we know it. true false 2. A major factor in the spread of transspecies hybrid viruses is A. lack of vaccines against these novel viruses B. host organisms lack antibodies against these novel pathogens C. there is no herd immunity against novel pathogens D. all of the above 9. The Drake Equation describes the odds of finding intelligent life...
1. About 1 in 5 solar systems outside of our solar system has an Earth-sized planet...
1. About 1 in 5 solar systems outside of our solar system has an Earth-sized planet that could support life as we know it. true false 2. A major factor in the spread of transspecies hybrid viruses is A. lack of vaccines against these novel viruses B. host organisms lack antibodies against these novel pathogens C. there is no herd immunity against novel pathogens D. all of the above 9. The Drake Equation describes the odds of finding intelligent life...
I.       According to Kepler’s Law, the planets in our solar system move in elliptical orbits around...
I.       According to Kepler’s Law, the planets in our solar system move in elliptical orbits around the Sun. If a planet’s closest approach to the Sun occurs at t = 0, then the distance r from the center of the planet to the center of the Sun at some later time t can be determined from the equation r = a (1 – e cos f) where a is the average distance between centers, e is a positive constant that...
3) Consider a spherical planet in our solar system with radius, R, that behaves like a...
3) Consider a spherical planet in our solar system with radius, R, that behaves like a perfect blackbody, absorbing all of the sunlight hitting its surface and radiating light isotropically according to its temperature. At what range of distances from the Sun could this planet support liquid water on its surface? Hint: Solve for the equilibrium temperature of the planet where the light energy it absorbs equals the energy radiated away, and then find the distances where this temperature is...
Python Programming You can calculate a person’s weight on the different planets within our solar system...
Python Programming You can calculate a person’s weight on the different planets within our solar system by multiplying their mass by the gravity factor on the surface of the planet. Weight = Earth Weight x Surface Gravity Factor Planet Surface Gravity Factor Mercury 0.38 Venus 0.91 Moon 0.165 Mars 0.38 Jupiter 2.34 Saturn 0.93 Uranus 0.92 Neptune 1.12 Pluto 0.066 \ For example if you weigh 100 pounds on earth on Mars you would be: Mars Weight 38 = 100...
Using C# Create a class named Inches To Feet. Its Main()method holds an integer variable named...
Using C# Create a class named Inches To Feet. Its Main()method holds an integer variable named inches to which you will assign a value. Create a method to which you pass inches. The method displays inches in feet and inches. For example, 67 inches is 5 feet 7 inches.
Create a class using C# named InchesToFeet. Its Main()method holds an integer variable named inches to...
Create a class using C# named InchesToFeet. Its Main()method holds an integer variable named inches to which you will assign a value. Create a method to which you pass inches. The method uses 2 ref parameters: feet, inches left of type int and a parameter that is not ref of type int to which you pass inchesinches. For example, 67 inches is 5 feet 7 inches.
Life has been found on a newly discovered planet not too far from our solar system!...
Life has been found on a newly discovered planet not too far from our solar system! The planet is named Nairb. A mission was sent to Nairb to learn more about these new life forms and the following data was obtained. The life forms on Nairb have a similar appearance to those of earth. These new life forms are also composed of many very similar molecular building blocks to life forms on earth, for example: amino acids and lipids are...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT