The complete program is given below.
Here is the complete main()
.
Of course, the program still cannot be run because the class Car
has not yet been defined.
import java.util.Scanner ;
import Car;
class MilesPerGallon
{
public static void main( String[] args )
{
Scanner scan = new Scanner(System.in);
double startMiles, endMiles, gallons;
System.out.print("Enter first reading: " );
startMiles = scan.nextDouble();
System.out.print("Enter second reading: " );
endMiles = scan.nextDouble();
System.out.print("Enter gallons: " );
gallons = scan.nextDouble();
Car car = new Car( startMiles, endMiles, gallons );
System.out.println( "Miles per gallon is " + car.calculateMPG() );
}
}
We still need a definition for class Car
.
Can a programmer write a definition for the class Car
?