I'm creating an odometer program.
"The problem to solve is define a class Odometer that will be used to track fueland mileage for an automobile. The class should have member variables to track the miles driven and the fuel efficiency of the vehicle in miles per gallon. Include a mutator function to reset the odometer to zero miles, and mutator function to set the fuel efficieny, a mutator function that acepts miles driven for a trip and adds it to the odometer's total, and an accessor method that returns the number of gallons of gasoline that the vehicle has consumed sinced the odometer was last reset"
Here is what I have so far.
import java.util.Scanner;
public class Odometer
{
public static void main(String args[])
{
Odometer first = new Odometer();
Scanner keyboard = new Scanner(System.in);
System.out.println("How many miles did you drive?");
double Miles = keyboard.nextDouble();
first.getMiles();
System.out.println("What is the MPG?");
double MPG = keyboard.nextDouble();
first.getMPG();
public int Fuel, Miles, MPG;
{
Fuel = 0;
Miles = 0;
MPG = 0;
}
public double getFuel()
{
Fuel = 0;
return Fuel;
}
public double getMiles()
{
Miles = 0;
return Miles;
}
public double getMPG()
{
MPG = 0;
return MPG;
}
}
}
I get an error at lines 20 and 42 which are illegal start of expression and class/interface/enum expected. I have a feeling this is due to my braces and their placements but I've tried so many different braces in areas that just result in more errors. If I try to add a text line to output a value it gives me an identifier error.