* @(#)Car.java
 *Chp.3 3.5
 * @author Alec Ziff
 * @version 1.00 2011/9/23

public class Car {
    public Car(double fuelEffciency) //all values are in miles per gallon

    	efficiency= fuelEfficiency;

    public void addGas(double gas)
    	double newFuel= fuel + gas;
    	fuel= newFuel;
 		public double drive( double distance)
 			double fuelLevel = fuel - (distance/efficiency);
 			fuel= fuelLevel;
 			return fuel;
		public double getGasInTank()
			return fuel;
		private double fuel;
		private double efficiency;

Recommended Answers

All 7 Replies

A lot of errors.

You forgot to post your errors.

Figured it out.But I have a new question on its tester class.

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

It says it cannot find the symbol on line 12. that would be the "Car myMysteryMachine = ...

Please post the full text of the error message.

error: cannot find symbol line 12

does anyone know?

Please copy and paste the FULL text of the error message. You are leaving parts of it off.

Here is a sample:

TestSorts.java:138: cannot find symbol
symbol  : variable var
location: class TestSorts
         var = 2;
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.