Advertisement
jinglis

Miles Driven

Jul 8th, 2014
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.01 KB | None | 0 0
  1. /* Name: James Inglis
  2.  * Date: 7/8/14
  3.  * This program takes the capacity of the gas tank, gets the miles per gallon,
  4.  * and calculates the number of miles that can be driven without refueling.
  5.  */
  6.  
  7.  
  8. import java.util.*;
  9.  
  10. public class Num10
  11. {
  12.    static Scanner console = new Scanner(System.in);
  13.    
  14.    public static void main(String[] args)
  15.    {
  16.       double capacity, milesPerGallon, numMiles;
  17.      
  18.      
  19.       // Getting the capacity(in gallons).
  20.       System.out.print("Enter in the capacity(in gallons): ");
  21.       capacity = console.nextDouble();
  22.       System.out.println();
  23.      
  24.       // Getting the miles per gallon.
  25.       System.out.print("Enter in the miles per gallon: ");
  26.       milesPerGallon = console.nextDouble();
  27.       System.out.println();
  28.      
  29.       // Calculating number of miles.
  30.       numMiles = capacity * milesPerGallon;
  31.      
  32.      
  33.       System.out.print("The number of miles your automobile can go without refueling: " + numMiles);
  34.      
  35.   }
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement