This program goes where no program has gone before, exploring new frontiers in C++. The program performs calculations concerning weight on various planets as well as travel time between planets. In main, use vectors to hold planet names, distance from the sun, and the specific gravity on each planet. These are parallel vectors, so that the information at a position in each vector refers to information concerning the same planet. Your program should first declare variables, include your vectors. Display your course header with the program title and a brief introduction using a cout. Load the data into the three vectors. Start a do while loop as your Play loop. Ask for the user’s name, Earth weight, the speed they want to travel and the planet they wish to visit. You will need to provide a menu with the planet names and a way for the user to select the chosen destination. Your interaction with the user should look similar to this: Using the data you have obtained from the user, determine the user’s weight on the destination planet and the travel time in hours. These equations might be useful: Weight on New Planet = Weight on Earth * Relative Surface Gravity of New Planet Travel Time (hours) = Travel Distance (miles) / Speed of Travel(mph) Use the data in this table to load the arrays: Planet Distance from Sun (millions of miles) Surface Gravity as a Percent of Earth’s Gravity Mercury 36 0.27 Venus 67 0.86 Earth 93 1.00 Mars 141 0.37 Jupiter 483 2.64 Saturn 886 1.17 Uranus 1782 0.92 Neptune 2793 1.44 Display the traveler’s name, weight on Earth, the destination planet and weight on that planet. Also report travel time results: Break down the travel time into years, days and hours. You may use 24 hours in a day and 365 days in a year (ignore leap years). Display the number of years, days and hours required for the trip. Your program should have only one set of result variables. The code for the calculations and resultant output should be written in only one place in your program. Do not duplicate code and calculation for each planet. Make your program as efficient as possible without losing clarity. Ask the user if they would like to calculate another space trip. Remember to tell the user the choices for an answer. If they say yes, loop up to the top of the Play Loop. When the user is done, present a good-bye message. Set the precision, etc, so you are reporting floating point numbers with 2 decimal places. Use functions to get information from the user, fill vectors, complete calculations and display menus and final report.
This
Your program should first declare variables, include your vectors.
Display your course header with the program title and a brief introduction using a cout. Load the data into the three vectors. Start a do while loop as your Play loop.
Ask for the user’s name, Earth weight, the speed they want to travel and the planet they wish to visit. You will need to provide a menu with the planet names and a way for the user to select the chosen destination.
Your interaction with the user should look similar to this:
Using the data you have obtained from the user, determine the user’s weight on the destination planet and the travel time in hours.
These equations might be useful:
Weight on New Planet = Weight on Earth * Relative Surface Gravity of New Planet
Travel Time (hours) = Travel Distance (miles) / Speed of Travel(mph)
Use the data in this table to load the arrays:
Planet |
Distance from Sun (millions of miles) |
Surface Gravity as a Percent of Earth’s Gravity |
Mercury |
36 |
0.27 |
Venus |
67 |
0.86 |
Earth |
93 |
1.00 |
Mars |
141 |
0.37 |
Jupiter |
483 |
2.64 |
Saturn |
886 |
1.17 |
Uranus |
1782 |
0.92 |
Neptune |
2793 |
1.44 |
Display the traveler’s name, weight on Earth, the destination planet and weight on that planet. Also report travel time results: Break down the travel time into years, days and hours. You may use 24 hours in a day and 365 days in a year (ignore leap years). Display the number of years, days and hours required for the trip.
Your program should have only one set of result variables. The code for the calculations and resultant output should be written in only one place in your program. Do not duplicate code and calculation for each planet. Make your program as efficient as possible without losing clarity.
Ask the user if they would like to calculate another space trip. Remember to tell the user the choices for an answer. If they say yes, loop up to the top of the Play Loop. When the user is done, present a good-bye message.
Set the precision, etc, so you are reporting floating point numbers with 2 decimal places.
Use functions to get information from the user, fill vectors, complete calculations and display menus and final report.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 3 images