Hello,
I am new to programming and struggling through trying to learn. Everything was going well, then I encountered the following error:
class [class name] is public, should be declared in a file names [class name].java
Here is the code I am working with:
class Vehicles {
public static void main(String args[]) {
Vehicle minivan = new Vehicle();
Vehicle sportscar = new Vehicle();
int range1, range2;
// assign values to fields in minivan
minivan.passengers = 7;
minivan.fuelcap = 16;
minivan.mpg = 21;
// assign values to fields in sportscar
sportscar.passengers = 2;
sportscar.fuelcap = 15;
sportscar.mpg = 28;
System.out.println("Minivan can carry " + minivan.passengers + ".");
minivan.range();
System.out.print.ln("Sportscar can carry " + sportscar.passengers + ".");
sportscar.range();
}
}