Question
Define a class called Odometer that will be used to track fuel and mileage for an automotive vehicle. Include private member variables to track the
Define a class called Odometer that will be used to track fuel and mileage for an automotive vehicle. Include private member variables to track the miles driven and the fuel efficiency of the vehicle in miles per gallon. The class should have a constructor that initializes these values to zero. Include a member function to reset the odometer to zero miles, a member function to set the fuel efficiency, a member function that accepts miles driven for a trip and adds it to the odometers total, and a member function that returns the number of gallons of gasoline that the vehicle has consumed since the odometer was last reset. Use your class with a test program that creates several trips with different fuel efficiencies.
// Two test trips// trip1: Fuel efficiency 45// log Miles first for 100 miles and after that for another 50 miles// trip1: Fuel efficiency 13// log Miles first for 100 miles and after that for another 50 milesOdometer trip1, trip2;
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