public class CarTester {
	
	public static void main (String[] args)
	{
		Car myMysteryMachine = new Car (1000); // Car gets 1000 miles per gallon
		myMysteryMachine.addGas(20); // 20 gallons of gas are added to the tank
		myMysteryMachine.drive(100); // Driving the car 100 miles
		System.out.println(myMysteryMachine.getGasInTank()); // Method prints the remaining fuel
		
	}
}

Recommended Answers

All 3 Replies

its referring to the Car myMysteryMachine = new Car (1000); // Car gets 1000 miles per gallon

Have you declared a constructor Car(int) ?

When you get: "cannot find symbol" it is usually because you are using a method or class that doesn't exist.

Meaning that you either haven't imported the class or you are calling the method/constructor with the wrong arguments or return type, or you simply have misspelled the method/constructor.

Or just as the messages says that method/constructor (Car(int)) doesn't exists

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.