@@ -0,0 +1,3244 @@
+/** A class that creates an Odometer object to track fuel and mileage for a car.%0A *  Class contains instance variables to track the miles driven and the fuel %0A *  efficiency in miles per gallon. Class includes mutator methods to reset the%0A *  odometer to 0 miles, to set the fuel efficiency and to accept miles driven%0A *  for a trip and add it to odometer total. Class includes an accessor method%0A *  that returns the number of gallons of gas the car has consumed since the %0A *  odometer was last reset. See test program %22OdometerTest.java%22 that creates%0A *  several trips with different fuel efficiencies.%0A */%0A%0Apackage odometertest;%0A%0Aimport java.util.Scanner;%0A%0A/**%0A *%0A * @author k8port%0A */%0Apublic class Odometer %7B%0A    %0A    // class variable%0A    private double miles; // the miles driven in a trip%0A    private double mpg;   // the fuel efficiency of the vehicle in miles per gallon%0A    %0A    // constructors%0A    /** No argument constructor sets miles driven to 0 and fuel efficiency to %0A     *  average combined fuel efficiency for 2014 vehicles.%0A     */%0A    public Odometer() %7B%0A        miles = 0;%0A        mpg = 29.5;%0A    %7D%0A    %0A    // mutator and accessor methods%0A    /** No argument method to reset the odometer to 0.%0A     * %0A     */%0A    public void resetZero() %7Bmiles = 0;%7D;%0A    %0A    /** Method that allows user to set the fuel efficiency of a vehicle.%0A     *  Uses Scanner to get input from user instead of argument.%0A     */%0A    public void setMPG() %7B%0A        Scanner scan = new Scanner(System.in);%0A        System.out.println(%22Set the fuel efficiency of your vehicle.%22);%0A        System.out.println(%22What is the combined (city/highway) fuel efficiency of the car?%22);%0A        mpg = scan.nextDouble();%0A        while (mpg %3C 10 %7C%7C mpg %3E 150) %7B%0A            System.out.println(%22Error entering fuel efficiency. Please reenter.%22);%0A            mpg = scan.nextDouble();%0A        %7D%0A    %7D%0A    %0A    /** Method that allows user to input miles driven for a trip and adds it to%0A     *  the odometer total. Also tells user how much gas was used for these miles.%0A     */%0A    public void acceptMiles() %7B%0A        double trip;%0A        Scanner scan = new Scanner(System.in);%0A        System.out.println(%22How many miles were driven on this trip?%22);%0A        trip = scan.nextDouble();%0A        while (trip %3C 0) %7B%0A            System.out.println(%22You must enter a positive number or 0 if no trip was taken.%22);%0A            trip = scan.nextDouble();%0A        %7D%0A        miles += trip;%0A    %7D%0A    %0A    /** Method that allows user to request price of gas based on current odometer%0A     *  reading.%0A     *  @return the number of gallons of gas used since odometer was last set%0A     */%0A    public double getGallons() %7Breturn miles/mpg;%7D%0A    %0A    // other methods%0A    /** Method to test equality of Odometer objects.%0A     * @param other the other Odometer%0A     * @return true if objects are the same%0A     */%0A    public boolean equals(Odometer other) %7B%0A        return (mpg == other.mpg && miles == other.miles);%0A    %7D%0A    %0A    /** Method that returns String representation of Odometer object.%0A     *  @return String representing Odometer object.%0A     */%0A    @Override%0A    public String toString() %7B%0A        return miles + %22 miles driven at %22 + mpg + %22 miles per gallon.%22;%0A    %7D%0A%7D   %0A%0A

Create Odometer.java