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)
- {
- Scanner scan = new Scanner(System.in);
- System.out.println("How man miles have you driven?");
- float milesDriven = scan.nextFloat();
- System.out.println("How many gallons did you use?");
- float gasGallons = scan.nextFloat();
- float result = milesDriven / gasGallons;
- System.out.printf("Your gas mileage is: %.9f%n", result);
- if(result < 30)
- {
- System.out.println();
- System.out.println("You are getting good gas mileage!");
- }
- else if(result > 30)
- {
- System.out.println();
- System.out.println("This is not good gas mileage, perform maintenance on vehicle.");
- }
- scan.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment