A Test Program for FuelLog

 [Previous Chapter]  [Previous Page]  [Contents]  [Next Page]  [Next Chapter]

TestFuelLog.java
import RitIo;

class TestFuelLog {

   public static void main(String args[]) {
      double initialMileage;  // initial mileage reading
      double mileage;         // mileage reading
      double gallons;         // amount of fuel at a stop
      double milesPerGallon;
      FuelLog log;

      // Get initial mileage and create a new fuel log

      initialMileage = RitIo.getDouble("Initial mileage: ");
      log = new FuelLog(initialMileage);

      // Process readings from the first gas station stop

      System.out.println("Readings from the first gas " +
         "station stop:");
      mileage = RitIo.getDouble("Mileage: ");
      gallons = RitIo.getDouble("Gallons: ");
      log.fillUp(mileage, gallons);
      System.out.println("Miles per gallon: " +
         log.milesPerGallon());

      // Process readings from the second gas station stop

      // ...
   }
}

 [Previous Chapter]  [Previous Page]  [Contents]  [Next Page]  [Next Chapter]
Copyright © 2001, 2002 Andreas Borchert, converted to HTML on February 11, 2002