Write a C++ program that asks the user to enter the number corresponds for a planet...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 doesn't 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 Mercury Venus Earth Mars Jupiter Saturn Uranus Neptune Weight Multiplier 0.4155 0.8975 1.0 0.3507 2.5374 1.0677 0.8947 1.1794 Remember Don't Repeat Yourself (DRY) in your code. Set the weight multiplier depending on which planet entered and then calculate and print the weight only once. 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: 0 You entered an invalid number; it should be a number from 1 to 8. Enter for planet: 9 You entered an invalid number; it should be a number from 1 to 8. Enter for planet: -1 You entered an invalid number; it should be a number from 1 to 8. Enter for planet: 7 Enter your weight in pounds: -100 Weight must be greater than 0. Enter your weight in pounds: 100 You will weigh 89.47 pounds on planet Uranus. 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 doesn't 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 Mercury Venus Earth Mars Jupiter Saturn Uranus Neptune Weight Multiplier 0.4155 0.8975 1.0 0.3507 2.5374 1.0677 0.8947 1.1794 Remember Don't Repeat Yourself (DRY) in your code. Set the weight multiplier depending on which planet entered and then calculate and print the weight only once. 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: 0 You entered an invalid number; it should be a number from 1 to 8. Enter for planet: 9 You entered an invalid number; it should be a number from 1 to 8. Enter for planet: -1 You entered an invalid number; it should be a number from 1 to 8. Enter for planet: 7 Enter your weight in pounds: -100 Weight must be greater than 0. Enter your weight in pounds: 100 You will weigh 89.47 pounds on planet Uranus.
Expert Answer:
Related Book For
Starting Out With Java From Control Structures Through Data Structures
ISBN: 9780133957051
6th Edition
Authors: Tony Gaddis
Posted Date:
Students also viewed these computer network questions
-
A regular language is a language that can be defined by a regular expression. 0 2 . 1 Complete the unshaded cells of Table 1 to show which of the statements about regular languages are true and which...
-
Maria is opposed to the idea of same-sex marriage. In a recent conversation in the school cafeteria, Maria argues, "If homosexuals are allowed to marry, then why not allow polygamy or other kinds of...
-
Find the Fourier series of the function shown in Fig. 17.61. f(t) 0 1 2 3 -1
-
What practical steps would you take to limit escalation of commitment in a situation of strong groupthink?
-
A rectangular wire loop enclosing an area \(A=0.40 \mathrm{~m}^{2}\) is inside a long cylindrical solenoid with two windings per \(\mathrm{mm}\). The area vector of the loop is aligned with the axis...
-
Ronica Kluge and Sam Edwards formed a partnership on May 1, 20-1. Kluge contributed $120,000 and Edwards contributed $50,000. During the year, Kluge contributed an additional $30,000. The partnership...
-
1.Discuss the rationale and significance of the Security Market Line (SML) as a representation of the valuation of risky securities. 2.Outline five of the positive characteristics that are...
-
The primary purpose of a cash budget is to Determine the level of investment in current and fixed assets. Determine financing needs. Provide a detailed plan of future cash flows. Determine the...
-
QUESTION 3 A user can request a quiz for the system. The system picks a set of questions from its database and compose them together to make a quiz. It rates the user's answers and gives hints if the...
-
Challenge The objective of this exercise is to discriminating between three species of Iris from the measurements of their petals and sepals. Your challenge will be to write your code in 20 lines or...
-
Simplify it (6-8 - + +8) sJ+ "
-
To solve the separable differential equation we must find two separate integrals: dy = help (formulas) and 10 da = help (formulas) The first integral we integrate by substitution: help (formulas)...
-
1. What is a doubling time? Suppose a population has a doubling time of 15 years. By what factor will it grow in 30 years? Choose the correct definition of a doubling time below. OOOO A. The time...
-
How many new automobiles were sold in the US in 2011?
-
Time Solutions, Inc. is an employment services firm that places both temporary and permanent workers with a variety of clients. Temporary placements account for 70% of Time Solutions' revenue;...
-
The financial statements for the business of Jets Ski Equipment are shown below. Additional information 1. All purchases and sales of inventories are on credit. 2. On 1 July 2019, J. Waters injected...
-
Some of the most recent financial statements for Hyland Pty Ltd are shown below. Additional information 1. All purchases and sales of inventories are on credit. 2. On 1 July 2020, the shareholders...
-
The statement of cash flows for Cash4Cars Ltd follows. Ignore GST. Required (a) Explain the information that would be presented in Note 29 of Cash4Cars Ltds financial statements. (b) Explain the...
Study smarter with the SolutionInn App