Answered step by step
Verified Expert Solution
Question
1 Approved Answer
//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
//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 aCostPerPound = 1000; //Cost to get one pound 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 bCostPerPound = 1250; //Cost to get one pound 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
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started