Write a Java Program that meets the following requirements

Write a Java Program that meets the following requirements:

Define a class called Odometer that will track fuel and mileage for an automotive vehicle. The class should have member variables to track the miles driven and the fuel inefficiency of the vehicle in miles per gallon. Include a mutator function to reset the odometer to zero miles, a mutator function to set the fuel efficiency, a mutator function that accepts miles driven for a trip and adds it to the odometer’s total, and an accessor 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. You should decide which variable should be public, if any.

Sample Run:

For your fuel-efficient small car:
After 100 miles, 2.22 gallons used. After another 50 miles, 3.33 gallons used. For your gas guzzler:
After 100 miles, 7.69 gallons used. After another 50 miles, 11.54 gallons used.

Complete Answer:

Get Instant Help in Homework Asap
Get Instant Help in Homework Asap
Calculate your paper price
Pages (550 words)
Approximate price: -
Open chat
1
Hello 👋
Thank you for choosing our assignment help service!
How can I help you?