Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

-include a default constructor that initializes all instance variables. -include

ID: 3676281 • Letter: #

Question

-include a default constructor that initializes all instance variables.

-include getters and setters for each instance variable

-overload the constructor to accept a tripmeter value

-include an initializeTrip method that resets the trip meter

include a startTrip method that gets the odometer reading and starts the tripmeter

include a stopTrip method that gets input from the user as to how many miles were traveled on a trip

you must be able to start and stop the trip during the session

Save the odometer value each time the program starts

The file name must be odometerReading.txt and contain 1100(for 1100miles)

Overload the toString method to return the original odometer reading, the trip meter reading and the final odometer reading

calculate the total miles of the trip

2. Write a driver application class that USES and VERIFIES that all methods of the Automobile class work correctly. You must prompt the user for inputs.

use this code for Main to test your class:

public class Main

{

public static void(String[] args)

{

Automobile auto = new Automobile();

auto.initializeTrip();

auto.startTrip();

auto.stopTrip();

auto.startTrip();

auto.stopTrip();

auto.startTrip();

auto.stopTrip();

auto.startTrip();

auto.stopTrip();

auto.calculateDistance();

}

}

need this in an hour and a half. thanks!

Explanation / Answer

public class AutomobileDemo
{
public static void main(String[] args)
{
// Create Automobile objects by 'new' operator and calling constructor
Automobile c1 = new Automobile("Toyota Camry", 0, 2.0);
Automobile c2 = new Automobile("Nissan Maxima", 1100, 5.4);

// Drive c1 for 1100 miles
c1.Drive(1100);
System.out.println(c1.getModel() + " has " +
c1.getOdometer() + " miles");

// c2 remains the same
System.out.println(c2.getModel() + " has " + c2.getOdometer() + " miles");
}
}