View difference between Paste ID: exRvqEuE and FzRw8CFh
SHOW: | | - or go back to the newest paste.
1
import java.util.Scanner;
2
3-
public class CalcPyramidVolume {
3+
public class MileageCalc {
4-
   private double pyramidVolume ( double baseLength, double baseWidth, double pyramidHeight);
4+
   public double convKilometersToMiles(double numKm) {
5-
   double volume;
5+
      double milesPerKm = 0.621371;
6-
   double baseArea;
6+
      return numKm * milesPerKm;
7-
   baseArea = baseLength * baseWidth;
7+
8-
   volume = (baseArea * pyramidHeight)/3;
8+
 
9-
   return volume;
9+
   public double convLitersToGallons(double numLiters) {
10
     double litersPerGal = 0.264172;
11-
   public static void main (String [] args) {
11+
     return numLiters * litersPerGal;
12-
      CalcPyramidVolume volumeCalculator = new CalcPyramidVolume();
12+
  }
13-
      System.out.println("Volume for 1.0, 1.0, 1.0 is: " + volumeCalculator.pyramidVolume(1.0, 1.0, 1.0));
13+
 
14
   public double calcMpg(double distMiles, double gasGallons) {
15
      System.out.println("FIXME: Calculate MPG");
16
      return 0.0;
17
   }
18
19
   public static void main(String[] args) {
20
      Scanner scnr = new Scanner(System.in);
21
      double distKm;
22
      double distMiles;
23
      double gasLiters;
24
      double gasGal;
25
      double userMpg;
26
      MileageCalc tripOdometer = new MileageCalc();
27
   
28
      System.out.println("Enter kilometers driven: ");
29
      distKm = scnr.nextDouble();
30
      System.out.println("Enter liters of gas consumed: ");
31
      gasLiters = scnr.nextDouble();
32
   
33
      distMiles = tripOdometer.convKilometersToMiles(distKm);
34
      gasGal = tripOdometer.convLitersToGallons(gasLiters);
35
      userMpg = tripOdometer.calcMpg(distMiles, gasGal);
36
   
37
      System.out.println("Miles driven: " + distMiles);
38
      System.out.println("Gallons of gas: " + gasGal);
39
      System.out.println("Mileage: " + userMpg + " mpg");
40
   }
41
}