Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class GasMileage {
- public static void main(String[] args) {
- double gasConsumed = 0.0, distanceTraveled = 0.0, milesPerGallon = 0.0;
- Scanner scan = new Scanner(System.in);
- System.out.print("Please enter how much gas your car consumed: ");
- gasConsumed = scan.nextDouble();
- System.out.print("Please enter the distance you have traveled: ");
- distanceTraveled = scan.nextDouble();
- milesPerGallon = distanceTraveled / gasConsumed;
- System.out.println("Your car had a fule economy of " + milesPerGallon + " during this trip.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement