The data of a Car object should be:
The names of the variables are up to the programer.
Here is the program with some of the Car
definition
filled in:
import java.io.* ; class Car { // instance variables int startMiles; // Stating odometer reading int endMiles; // Ending odometer reading double gallons; // Gallons of gas used between the readings // constructor // methods } class MilesPerGallon { public static void main( String[] args ) { Car car = new Car( 32456, 32810, 10.6 ); System.out.println( "Miles per gallon is " + car.calculateMPG() ); } }