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
-
Problem 8: (a) Consider a spherical shell of inner radius r, outer radius r2, thermal conductivity k, and emissivity . The outer surface of the shell is subjected to radiation to surrounding surfaces...
-
Question 3 The pressure (in kPa) in a capillary is given by p(x)=2.3-0.9x Where x is the distance along the capillary in mm. The total length of the capillary is L = 1.5 mm. The concentrations of...
-
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 for the signal in Fig. 17.58. Evaluate f(t) at t = 2 using the first three nonzero harmonics. f(r) 4 -4-20246
-
QUESTION TWO The Research department of Pogba Limited has presented Amos with the data below. Day Stock Price (Kshs) Monday 11.5 Tuesday 14 Wednesday 12.5 Thursday 13.5 Friday 12 They have requested...
-
Choose letter \(\mathrm{C}\) (for committed fixed cost) or \(\mathrm{D}\) (for discretionary fixed cost) to indicate the type of each of the following described costs. a. Professional meeting...
-
Students arrive at the Administrative Services Office at an average of one every 15 minutes, and their requests take on average 10 minutes to be processed. The service counter is staffed by only one...
-
A company has improved its production process. Under the old process, 17 workers could produce 4,183 units per hours and the materials cost $58 per unit of output. Workers are paid $16 per hour and...
-
The following are selected 2020 transactions of Pronghorn Corporation. Sept. 1 Purchased inventory from Encino Company on account for $59,600. Pronghorn records purchases gross and uses a periodic...
-
How do database management systems handle table locking and concurrency control mechanisms to ensure data consistency and isolation levels during concurrent read and write operations on shared tables...
-
Is conflict resolution the most important skill that leaders need? Why or why not? What other skills are important in building working relationships?
-
How do NoSQL databases diverge from traditional relational databases in terms of data modeling paradigms, consistency models, and scalability architectures, and what are the implications for...
-
How do relational databases integrate with emerging technologies and paradigms, such as microservices architecture, cloud computing, and containerization, to support modern application development...
-
Available infrastructure, skill needs and response time mostly affect which of the four Global Network Design Decisions?
-
The table below provides summary information about subjects that students are studying in a class, by sex and subjects studied. Male Female Total Economics 10 12 22 Statistics 13 26 39 Other 5 14 19...
-
Study the pictures/images below. Obviously these was focus on LT sociology, anthropology and poltical science. Try to do some analysis by finding clues that are synonymous with the main concepts....
-
The theory of monopolistic competition is based on three characteristics: (1) product _________, (2) many _________, and (3) free _________.
-
Monopolistic competitive sellers are price _________ and they do not regard price as given by the market. Because products in the industry are slightly different, each firm faces a(n)...
-
In the short run, equilibrium output is determined where marginal revenue equals marginal _________. The price is set equal to the _________ the consumer will pay for this amount.
Study smarter with the SolutionInn App