Answer:
Of course!
Class Definition
Here is the miles per gallon program,
now with a skeleton for the Car class.
To keep the program short, user interaction has been left out.
class Car
{
// instance variables
// 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() );
}
}
The source file must be named
MilesPerGallon.java after the name of
the class that contains main().
QUESTION 5:
Decide what variables should go in the data section. Look back to the Car class for the class to see what you need.