Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Name: James Inglis
- * Date: 7/8/14
- * This program takes the capacity of the gas tank, gets the miles per gallon,
- * and calculates the number of miles that can be driven without refueling.
- */
- import java.util.*;
- public class Num10
- {
- static Scanner console = new Scanner(System.in);
- public static void main(String[] args)
- {
- double capacity, milesPerGallon, numMiles;
- // Getting the capacity(in gallons).
- System.out.print("Enter in the capacity(in gallons): ");
- capacity = console.nextDouble();
- System.out.println();
- // Getting the miles per gallon.
- System.out.print("Enter in the miles per gallon: ");
- milesPerGallon = console.nextDouble();
- System.out.println();
- // Calculating number of miles.
- numMiles = capacity * milesPerGallon;
- System.out.print("The number of miles your automobile can go without refueling: " + numMiles);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement