Suppose that you are given the following Driver class, which includes a main method:
public class Driver { public static void main(String[] args) { double distance = 400.48; double fuel = 21.4; AutoTrip myTrip = new AutoTrip(distance, fuel); System.out.print("My car traveled " + myTrip.getDistance() + " miles "); System.out.println("on " + myTrip.getFuel() + " gallons of gasoline."); double mileage = myTrip.getMPG(); // get miles per gallon System.out.println("My mileage was " + mileage + "."); } }
Now suppose that executing main produces the following output:
My car traveled 400.48 miles on 21.4 gallons of gasoline.
My mileage was 18.714018691588787.
Implement the AutoTrip class so that it produces the indicated output.
public class AutoTrip { private double distance; private int fuel; public AutoTrip(double miles, int gallons){ distance = miles; fuel = gallons; } public double getDistance(){return distance;} public int getFuel(){return fuel;} public double getMPG(){return (distance/fuel);}
when i put this in the feedback says "The constructor you have written doesn't match the constructor call in the problem specification."