Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 2 Write a C + + program that asks the user to enter the number corresponds for a planet name and their weight on
Question
Write a C program that asks the user to enter the number corresponds for a
planet name and their weight on earth in pounds The chosen planet will be
selected from a menu displayed, and then enter the value for the weight in earth
in pounds.
The program will then calculate and then output the corresponding weight in the
planet selected by multiplying the weight on earth by the weight multiplier for
the planet selected. Weight multipliers are listed in the table below.
The program should output an error message if the user doesnt type a valid
number that corresponds to a planet name. See sample run below In addition,
check to ensure that weight is greater than
The prompt and the error message should make it clear to the user how a planet
name must be entered. Be sure to use proper formatting and appropriate comments
in your code. The output should be clearly labeled and neatly formatted.
Planet Name Weight Multiplier
Mercury
Venus
Earth
Mars
Jupiter
Saturn
Uranus
Neptune
Remember Dont Repeat Yourself DRY in your code. If same statements are
repeated in different branches of your ifelse, then take it out and do it only
once in a common path area of your code where it will be executed all the time
with no conditions.
A sample run of the program will produce something like this:
Mercury
Venus
Earth
Mars
Jupiter
Saturn
Uranus
Neptune
Enter # for planet:
Enter your weight in pounds:
You will weigh pounds on planet Mars.
Another sample run of the program will produce something like this, take note
when Invalid values entered, your program will display an error message and then
exit out shown below
Mercury
Venus
Earth
Mars
Jupiter
Saturn
Uranus
Neptune
Enter # for planet:
You entered an invalid number; it should be a number from to
Another sample run where the planet number is valid but the weight inputted is
invalid. Again, display error message and then exit out.
Mercury
Venus
Earth
Mars
Jupiter
Saturn
Uranus
Neptune
Enter # for planet:
Enter your weight in pounds:
Invalid weight. Weight must be greater than
Test your program to ensure it is working as it is supposed to be
You may use same test values shown above.
Remember to use meaningful names for your variables.
What to submit?
Use same file from Question above.
Label Question # in a new page, and then put our source code for question #
below the headingg screenshot or copy and paste
Copy paste of source code is fine if all format and indentation are kept.
And then followed by two different screenshots of the outputs when testing your
program with two different sets of input data for planet number and weight.
Remember to check that your outputs are correct.
Lastly, save your source code in case I will ask for it
Take note of how your program will be graded?
a Specifications
Is the program working?
And has all the requirements being met or not?
b Readability
Code is well organized, indented properly, and very easy to follow
c Documentation
Header comments at top of your program
Necessary documentation clearly explain what is being done, and close resemble your algorithm
d Efficiency
Code is efficient without sacrificing readability and understanding.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started