CPTR-142 Homework #6 - Due Monday 4/21/14
In program 5 an Odometer class was defined that can be used to
keep track of fuel and mileage for a vehicle. In addition to the
functions already defined we need two additional functions: 1)determine
the difference in gas mileage between two vehicles (i.e. subtraction).
This function should return a number with type double. 2) determine if
one vehicle's mileage is greater than another. This function should
return a bool type.
Write program 6 in which the Odometer class from program 5 is extended
to include the functions defined above. These functions should be
implemented to allow operators - (minus) and > (greater than) to be
used in a main program when these functions are needed. Note that the
difference function will return a numerical value and greater than
should return a boolean value. (With CodeBlocks in c++ mode you don't
need to specify an additional library to use bool as a data type).
The prototype for "minus" should likely return a double unless you are
keeping track of mileage to only the nearest integer value. Neither the
"minus" or "greater-than" prototypes will have a return datetype of Odometer.
Write a main that will declare two or more vehicles (i.e. objects
of type Odometer), put data into them, and then use the overloaded
subtraction function and greater-than function to demonstrate
operation.
Bring a printout of your main.cpp
file to class. Email the main.cpp files to
me but as you do that change the name to: name_programr6.cpp
where name represents your last name. And between name and
program6 is an underscore. I appreciate not having spaces
in your file names.
Larry Aamodt PhD, PE
Professor of Engineering and Computer Science
Walla Walla University
Contact:
via email: AamoLa (at) wallawalla.edu
via phone: x2058