The complete program is given below.
Here is the complete MilesPerGallon
.
Unfortunately, until you write the code for Car
the program can't be run.
import java.util.Scanner ;
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() );
}
}
Can a programmer write a definition for the class Car
?