Answered step by step
Verified Expert Solution
Question
1 Approved Answer
You need to make the overloaded constructor set the values not add to the values. You need to add a function (add_trip) that will add
You need to make the overloaded constructor set the values not add to the values. You need to add a function (add_trip) that will add the passed in to the values already there. I know that a few of you have finished the program. I apologize for the changes, but it can't work correctly the way I specified it in the assignment.
Clarification on what is in the files: odometer.hpp contains pseudo code and the class definition. odometer.cpp contains the code for the class odometer. main2 contains pseudo code for main and tests the odometer class.
C++
Desciption. You are going to write an Odometer class that will track fuel and mileage for an autormotive 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 mumber of gallons used. This function should add the miles to the miles driven and the gallons to the gallons used. 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 to0 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 taie h out of fuei tha Requirements Odometer must be implemented in a class with the a No global variables are to be used e requirenmentsStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started