declare variables, include your arrays.  Declare two struct variables to hold data.  The first will be the TravelerInfo struct, which holds name(string), weight(double),  newWeight(double) for the weight on the other planet, planetChoice ( int) and speed(int).  The second struct is the TravelTimeCalc struct.  It holds total travel time, years, days, and hours.  All are ints.  Both structs are declared in the Functions.h file.  Write out a program title and brief introduction using your Header function.  Pass the arrays to the FillPlanetInfo function, which will load the data into the three arrays.  Start a do while loop in main as your Play loop.  Pass the  function AskSpaceTravellerInfo a reference to the TravelerInfo struct variable and the array of planet names. Get 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. Pass the data you obtained (TravelerInfo variable), the TravelTimeCalc struct variable, and the 3 arrays into the CalculateTimeandWeight function, which will determine the user’s weight on the destination planet and the travel time in hours.  Call the Write function, passing the planet name array, a pointer to the filename, and the two structs, containing all the data to be presented to the user in a cout statement and to be written into a file.  Call the CalcTimes function to convert the total hours to years, days and hours. Use a stringstream to create a string with all of the output data which will be displayed to the user and  also written into a file.  Use two decimal places to display any numbers. Still in the Write function, call CreateFilename to create a filename from the user’s name and from today’s date.  Declare a static variable in CreateFilename, static int number = 1;  Increment number each time the function CreateFilename is called.  Use system time and date to get the integers needed to create this form of filename:  name _ month_day_year_number.txt.  Write the string you have created into this file. Return a string to Write containing  the filename. In Write, open the file and check to see if the file was opened.  Return a bool from the Write function indicating file success or failure.  Check the bool in main and report to the user that the file was created, and the filename and if not, that no file was created. Ask the user if they would like to calculate another space trip.  Remember to tell the user the choices for an answer.  If 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 numbers with 2 decimal places. equations: Weight on New Planet = Weight on Earth * Relative Surface Gravity of New Planet Travel Time (hours) = Travel Distance (miles) / Speed of Travel(mph) Planets, 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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

declare variables, include your arrays.  Declare two struct variables to hold data.  The first will be the TravelerInfo struct, which holds name(string), weight(double),  newWeight(double) for the weight on the other planet, planetChoice ( int) and speed(int).  The second struct is the TravelTimeCalc struct.  It holds total travel time, years, days, and hours.  All are ints.  Both structs are declared in the Functions.h file. 

Write out a program title and brief introduction using your Header function.  Pass the arrays to the FillPlanetInfo function, which will load the data into the three arrays.  Start a do while loop in main as your Play loop. 

Pass the  function AskSpaceTravellerInfo a reference to the TravelerInfo struct variable and the array of planet names. Get 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.

Pass the data you obtained (TravelerInfo variable), the TravelTimeCalc struct variable, and the 3 arrays into the CalculateTimeandWeight function, which will determine the user’s weight on the destination planet and the travel time in hours. 

Call the Write function, passing the planet name array, a pointer to the filename, and the two structs, containing all the data to be presented to the user in a cout statement and to be written into a file.  Call the CalcTimes function to convert the total hours to years, days and hours. Use a stringstream to create a string with all of the output data which will be displayed to the user and  also written into a file.  Use two decimal places to display any numbers.

Still in the Write function, call CreateFilename to create a filename from the user’s name and from today’s date.  Declare a static variable in CreateFilename, static int number = 1;  Increment number each time the function CreateFilename is called.  Use system time and date to get the integers needed to create this form of filename:  name _ month_day_year_number.txt.  Write the string you have created into this file. Return a string to Write containing  the filename.

In Write, open the file and check to see if the file was opened.  Return a bool from the Write function indicating file success or failure.  Check the bool in main and report to the user that the file was created, and the filename and if not, that no file was created.

Ask the user if they would like to calculate another space trip.  Remember to tell the user the choices for an answer.  If 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 numbers with 2 decimal places.

equations:

Weight on New Planet = Weight on Earth * Relative Surface Gravity of New Planet

Travel Time (hours) = Travel Distance (miles) / Speed of Travel(mph)

Planets, 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

 

AI-Generated Solution
AI-generated content may present inaccurate or offensive content that does not represent bartleby’s views.
steps

Unlock instant AI solutions

Tap the button
to generate a solution

Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education