Question: Program # 5 DUE: Specified on Canvas CS2020, Instructor: Carlson Program Purpose Practice designing and implementing programs in C++, creating classes with methods and data.

Program # 5 DUE: Specified on Canvas CS2020, Instructor: Carlson Program Purpose Practice designing and implementing programs in C++, creating classes with methods and data. Mandatory Instructions Write a C++ program solution to keep track of a road trip using a class Trip which will include information about the trip such as destination, distance traveled, total cost of gasoline, and number of gallons consumed. Trip Class Design a Trip class with private data members to store a distance, gas cost, gallons of gas and destination. Decide the most appropriate date types for these data members. Include public member functions in your class to allow the trip information to be set and retrieved (setName, getName, setDistance, getDistance, setCost, getCost, setGallons, getGallons). Also declare a default constructor that sets the data members to zero and an overloaded constructor that accepts all values for the Trip. These functions should all be defined as in-line functions. Type the class declaration with the Trip data members and these member functions (a.k.a. methods) into a file called prog5.h. This file should also include prototypes for other functions described below. These functions will be defined as out-of-line functions. In a separate file called prog5.cpp type in the function definitions (i.e., implementations) for the out-of-line functions. Be sure to qualify each function name in this file with the class name and scope resolution operator (i.e., Trip::) Create a third file named prog5client.cpp to demonstrate using the Trip class. The program should ask the user to enter trip information, set all data members in an instance of the Trip class to user input, and call methods of the class to compute various tasks. Use a sentinel controlled loop to allow the user to enter several trips, reuse your Trip object by dynamically allocating and deallocating between different trips. When user enters sentinel value 2 exit the program. Use enumerated type MenuChoice and define enumerators ADD and QUIT. To make your program more modular use other functions such as menu() function, getInput() function, etc. which should be called from main(). Prototypes for the required function are shown below. Your main() should be NO more than 11 C++ statements (function header, curly braces and white space not included in this count). void printHeading(); // prints the Welcome heading void printMenu(); // prints the menu options MenuChoice menu(); // returns MenuChoice void getInput(Trip*); // pointer to Trip instance is passed as an argument void showOutput(Trip*); // pointer to Trip instance is passed as an argument ============================================ Welcome to the Trip Calculator Application ============================================ 1. Add trip 2. Quit ============================================ Choice? 1 Destination? California Distance? 2376 Cost of gas? 164.60 Gallons? 69 ============================================ Your trip to California (2376 miles) Miles per gallon: 34.43mpg Cost per mile: $0.07 Cost per gallon: $2.39 ============================================ 1. Add trip 2. Quit ============================================ Use string constant to output this divider line everywhere you see it here. Program # 5 DUE: Specified on Canvas CS2020, Instructor: Carlson In addition to mutators and accessors your Trip class should have the following functions: double getMilesPerGallon() const; // returns mpg double getCostPerGallon() const; // returns cost per gallon double getCostPerMile() const; // returns cost per mile Program Documentation Provide documentation header for your program and for each function other than main(). // Program 5 // Description: Program description // Programmer: Your name // Class: CS 2020, spring 20xx // Function: Function name // Description: Function purpose // Programmer: Your name // Class: CS 2020, spring 20xx // Parameters: list and describe // Returns: describe What to turn in? Make sure you have completed your program according to the specifications given. Copy prog5.txt into your BGUnix cs2020 directory. Make a photo of your program by typing in the following commands at the prompt: $ photo prog5.log ( to start the photo utility) $ pwd ( to identify your current directory) $ ls -l ( to list all files in your directory lower case Ls not ones) $ ( to leave a blank line press the Enter key ) $ cat prog5.h ( to show your C++ header file) $ cat prog5.cpp ( to show your C++ class file) $ cat prog5client.cpp ( to show your C++ client file) $ g++ prog5.cpp prog5client.cpp ( to compile your program - creates a.out file) Program # 5 DUE: Specified on Canvas CS2020, Instructor: Carlson $ a.out < prog5.txt ( to test your file ) $ Ctrl+d ( to exit the photo session ) $ logout ( to logout of BGUnix) Upload the grade sheet to Canvas.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!