Answered step by step
Verified Expert Solution
Link Copied!

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 2
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 0.
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 0.4155
Venus 0.8975
Earth 1.0
Mars 0.3507
Jupiter 2.5374
Saturn 1.0677
Uranus 0.8947
Neptune 1.1794
Remember Dont Repeat Yourself (DRY) in your code. If same statements are
repeated in different branches of your if-else, 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.
4
A sample run of the program will produce something like this:
1) Mercury
2) Venus
3) Earth
4) Mars
5) Jupiter
6) Saturn
7) Uranus
8)Neptune
Enter # for planet: 4
Enter your weight in pounds: 200
You will weigh 70.14 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).
1) Mercury
2) Venus
3) Earth
4) Mars
5) Jupiter
6) Saturn
7) Uranus
8)Neptune
Enter # for planet: 0
You entered an invalid number; it should be a number from 1 to 8.
Another sample run where the planet number is valid but the weight inputted is
invalid. Again, display error message and then exit out.
1) Mercury
2) Venus
3) Earth
4) Mars
5) Jupiter
6) Saturn
7) Uranus
8)Neptune
Enter # for planet: 7
5
Enter your weight in pounds: -100
Invalid weight. Weight must be greater than 0.
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 1 above.
Label Question #2 in a new page, and then put our source code for question #2
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 (70%)
- Is the program working?
- And has all the requirements being met or not?
b) Readability (10%)
- Code is well organized, indented properly, and very easy to follow
c) Documentation (10%)
- Header comments at top of your program
- Necessary documentation clearly explain what is being done, and close resemble your algorithm
d) Efficiency (10%)
- Code is efficient without sacrificing readability and understanding.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

5. Identify and describe nine social and cultural identities.

Answered: 1 week ago

Question

2. Define identity.

Answered: 1 week ago

Question

4. Describe phases of majority identity development.

Answered: 1 week ago