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 odometer’s 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.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter11: Inheritance And Composition
Section: Chapter Questions
Problem 16SA
icon
Related questions
Question

c++

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 odometer’s 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.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr