Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with this program please C++, Thank you! The txt file is prog5.txt: 1 California 2376 164.60 69 3 0 1 Alaska 3791.7

I need help with this program please C++, Thank you!

image text in transcribed

image text in transcribed

The txt file is prog5.txt:

1 California 2376 164.60 69 3 0 1 Alaska 3791.7 307.26 130.75 1 Florida Keys 1363.6 128.18 54.5 2

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 mmber of gallons consumed. Trip ClaSS Design a Trip class with private data members to store a distance, gas cost, gallons ofgas and destination Decide the most appropriate date types for these data members. Include public member fimctions in your class to allow the trip information to be set and retrieved GetName, getName, setDistance, getDistance, setCost, gerCost, 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 fiumctions should all be defined as in-line fumctions. Type the class declaration with the Trip data members and these member functions (a ka methods) into a file called prog5.h. This file should also include prototypes for other finctions described below. These functions will be defined as out-of-line fimctions. In a separate file called prog5.cpp type in the function definitions (ie., inplementations) for the out-of-line fimctions. 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 progSclient 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 imput, 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 dynanically allocating and deallocating between different trips. When user enters sentinel value 2 exit the program Use emumerated type MmuChoice and define enumerators ADD and QUIT To make your program more modular use other functions such as menu fumction, getInput finction, etc. which should be called from mainO. Prototypes for the required function are shown below. Your main0 should be NO more than 11 Cstatements (fimction beader, curly braces and white space not included in this count). void printHeading); void printMenu); MenuChoice menuO; void getInput (Trip*); void showOutput (Trip); // prints the Welcome heading // prints the nenu options /I returns MenuChoice // pointer to Trip instance is passed as an argument // pointer to Trip instance is passed as an argument Welcone to the Trip Calculator Application Quit Choice Destination? California tance? 2376 Cost of gas? 164-60 Glions ? 69 Use string constant to output this divider line everywhere you see it here. Your trip to California (2376 niles) Miles per gallon: Cost per mile Cost per gallon: 34.43mpg 50.07 52.39 1. Add trip 2. Quit

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

Beginning Databases With PostgreSQL From Novice To Professional

Authors: Richard Stones, Neil Matthew

2nd Edition

1590594789, 978-1590594780

More Books

Students also viewed these Databases questions