Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write the test program(*/main.cpp), the headerfile (*/program.hpp), and the main C++ program (*/program.cpp) of the following with clear notes: The contents for each: 1)

Please write the test program(*/main.cpp), the headerfile (*/program.hpp), and the main C++ program (*/program.cpp) of the following with clear notes:

The contents for each:

1) program.hpp contains pseudo code and the class definition.

2) program.cpp contains the code for the class odometer.

3) main.cpp contains psuedo code for main and tests the odometer class.

Description: You are going to write an Odometer class that will track fuel and mileage for an automotive vehicle. The class should have member variables to track the miles driven (odometer reading), the fuel efficiency of the vehicle in miles per gallon, and the number of gallons used. Include a function to reset the number of miles driven to 0. This should also reset the other variables. You should have a constructor that accepts the miles driven for a trip and number of gallons used . This function should set the values, the miles, to the miles driven and the gallons to the gallons used. You need to add a function (add_trip) that will add the passed in to the values already there. It should calculate the fuel efficiency. You should have accessor functions to return the odometer reading, fuel efficiency, and gallons used since the odometer was last reset. There should be a function that will accept the number of miles to drive and return the number of gallons of gas needed based on the fuel efficiency to drive that number of miles. You are to write test code to make sure that your Odometer class works. You need to test at least 3 cases. This means you must use at least 3 Odometers and make sure they each work correctly. All of your functions in the Odometer class must be tested to show that they work. Testing the Odometer class is very open ended. This means that the proof of it working depends on you to make sure that in main you have tested all possibilities. The input and output is your responsibility to demonstrate a working class.

Class member variables all should be able to hold decimal numbers:

number of miles driven

number of gallons used

fuel efficiency

Class member functions

Default constructor

Constructor that will accept miles driven and gallons

Reset resets miles and gallons to 0

Accessor functions for each of the data

Given a number of miles driven, return the amount of fuel that will be needed based on the fuel efficiency

Requirements

Odometer must be implemented in a class with the above requirements.

No global variables are to be used.

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

Web Database Development Step By Step

Authors: Jim Buyens

1st Edition

0735609667, 978-0735609662

More Books

Students also viewed these Databases questions

Question

Describe three core values you would use to run your own company.

Answered: 1 week ago