Lab4 – Trip Calculator

 

Write a C++ program to calculate travel times for a number of predefined trips (use distance = rate * time for your calculations). Create 10 predefined trips, originating from Chicago, to various cities of your choice in the United States. Find and store the distance between cities in miles. List the pre-defined trips and prompt a user to select one of these trips, input a travel speed in miles per hour, then print the calculated duration (in hours). Continue until the user terminates the program.

 

Examine the problem description and identify a single primary data model to design as a C++ class. Your analysis should have identified a “trip” as the main object (noun) evident in the program description. This data model identification is critical to successful object-oriented programming. As discussed in the study notes, write your class definition in a header file (Trip.h), your class member function definitions in a separate class source file (Trip.C or .cpp), and your main application in a separate source file (lab4.C or .cpp). As described in the study notes, compile your program using the GNU C++ compiler, g++, as follows:

 

jdoe@shaula % g++ -c Trip.C

jdoe@shaula % g++ -c lab4.C

jdoe@shaula % g++ -o lab4 Trip.o lab4.o

 

 

To execute your program:

 

jdoe@shaula % lab4