Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Define a class called Odometer that will be used to track fuel and mileage for a vehicle. Include member variables to track the distance driven

image text in transcribed
Define a class called Odometer that will be used to track fuel and mileage for a vehicle. Include member variables to track the distance driven (in miles) and the fuel efficiency of the vehicle (in miles per gallon). The class will have a constructor that accepts one parameter and initializes distance to 0 and fuel efficiency to the value of its parameter. Include a member function to reset the odometer to 0 miles, a member function that accepts the 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 Odometer class in a program that would ask the user to input fuel efficiency and then create an Odometer object using your constructor to initialize the member variables to their appropriate values. Then the program would ask the user to input the miles driven for two trips and output the gallons of gas the vehicle consumed on these two trips. Then it will reset the odometer and repeat the procedure for two more trips

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

Introductory Relational Database Design For Business With Microsoft Access

Authors: Jonathan Eckstein, Bonnie R. Schultz

1st Edition

1119329418, 978-1119329411

More Books

Students also viewed these Databases questions