Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with C++ //Example program #include #include #include using namespace std; //Rocket cost consts const int aCostPerKm = 250.00; //Cost of the trip

I need help with C++ image text in transcribed
//Example program
#include
#include
#include
using namespace std;
//Rocket cost consts
const int aCostPerKm = 250.00; //Cost of the trip per km for a class A rocket
const int aCostPerKg = 1000; //Cost to get one kg of matter into orbit for a class A rocket
const int bCostPerKm = 325.00;//Cost of the trip per km for a class B rocket
const int bCostPerKg = 1250; //Cost to get one kg of matter into orbit for a class B rocket
//Astrononical distance consts
const int distToMoon = 384400; //Dist to moon (minimum trip length) in km
const int distToAstBelt = 350000000; //Dist to asteroid belt (maximum trip length) in km
//---------------------------------------------------------------------------
// Name: GetBoundedInput
// Parameters: Question, string, the YN question to ask. LowerBound/Upperbound, the bounds within
// which the user input must fall.
// Returns: input; the number the user entered. range is (Lowerbound, Upperbound)
// Purpose: This function returns the user's bounded response to a question
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Name: CalculateCost
// Parameters: const int totalWeight, const long totalDist, const char rocketClass, ref double cost
// Returns: none
// Purpose: Calculate the total cost of the trip given the user's input
// and the given global parameters and assign it to cost
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Name: CalculateClass
// Parameters: long totalDist
// Returns: char class. A for lighter rockets and B for stringent needs
// Purpose: Calculate the class of the rocket based on its distance and needs.
// Class B rockets are required for >100 passengers or trips longer than 1M km.
// Call GetBoundedInput to get the number of users(max 250) and return 'A' or 'B'
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Name: BookAnotherRide
// Parameters: ref char cont
// Returns: none
// Purpose: This function asks the user if they want to continue, checks to
// ensure that the user enters a 'Y' or a 'N', and returns the answer
//---------------------------------------------------------------------------
int main()
{
int totalWeight = 0;
long totalDist = 0;
double totalCost = 0;
char rocketClass = '\0';
char goAgain = 'N';
// these two lines print numbers with ',' after 3 digits
locale mylocale("");
cout.imbue(mylocale);
do
{
cout
"from the moon to the inner asteroid belt. Let's get started! ";
//totalWeight = GetBoundedInput(" What is the total weight of the passsengers and cargo? (Max 5000 kgs; no comma): ", 0, 5000);
//totalDist = 2 * GetBoundedInput(" What is the distance in km to your destination? (384,400 km to 350,000,000km; no commas): ",
// distToMoon, distToAstBelt);
//rocketClass = CalculateClass(totalDist);
//CalculateCost(totalWeight, totalDist, rocketClass, totalCost);
//cout
//
//BookAnotherRide(goAgain);
}while(goAgain != 'N');
return 0;
}
Your task is to write the required functions to complete the functionality inside of main. You're booking trips for the Inner Solar System Transit Service corporation. Youl schedule trips of up to 250 people and a total of 5000 kgs of cargo from Earth to anywhere from the moon to the inner asteroid belt. Amazing breakthroughs in technology and financial engineering have rendered the cost per km of the trip to $250/km for class "A' rockets and $325/km for the faster class B rockets Your goal is to modify hw4b.cpp to accomplish the goals set forth inside of main. 2. Design: Think about what the main program is doing. It is already written for you and you should not change it at all (other than removing the comment marks before function calls). Function descriptions are already provided at the top of the program. Begin by compiling and running the unmodified program to see what it does. Your goal is to create the functions that make the main program work For each function, look at how it is called by the main program. What kinds of parameters are being passed to the functions? Are these pass by value(const) or pass by reference (&)? What return types are needed? Start with GetBoundedinput. Uncomment the line that assigns a value to totalWeight First, create a version of the function that is syntactically correct with parameter passing that just does a cout and returns a fixed integer value, eg. 100, each time Next, fill in GetBoundedinput so it is fully functional, including error checking. Compile and test it untl you are satisfied that it is correct. Then, move on to the next function. Here's an example run of the program: Welcome to the Inner Solar System Space Transit System. You can book trips for passengers and cargo from the moon to the inner asteroid belt. Let's get started! What is the total weight of the passsengers and cargo? (Max 5000 kgs; no comma): 2000 What is the distance in km to your destination? (384,400 km to 350,000,000km; no commas):900000 Enter the number of passenger seats you require (250 max): 190 The cost for your trip on your class B rocket will cost $587 million. Do you want to book another ride? Enter (YIN): n The main program is writen for you. You just need to create the functions so that the function calls in the main program work to solve the overall problem All of the function descriptions are provided. You do not need additional functions. You should not modify the main program other than removing the comment symbols

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

Recommended Textbook for

SQL Server T-SQL Recipes

Authors: David Dye, Jason Brimhall

4th Edition

1484200616, 9781484200612

More Books

Students also viewed these Databases questions

Question

Discuss the six focus organizations used in this book.

Answered: 1 week ago