Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Program name: main2.cpp, odometer.cpp, ,odometer.hpp Rubrics that apply: All except makefile Points Possible: 100 Description You are going to write an Odometer class that will
Program name: main2.cpp, odometer.cpp, ,odometer.hpp Rubrics that apply: All except makefile Points Possible: 100 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 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 vour 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
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