/**
 * @(#)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;
}
}

Edited 5 Years Ago by Ezzaral: Added code tags. Please use them to format any code that you post.

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 = ...

Edited 5 Years Ago by Ezzaral: Added code tags. Please use them to format any code that you post.

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;
         ^
This article has been dead for over six months. Start a new discussion instead.