Advertisement
uktcar

02.3.07FuelTank

Mar 15th, 2023 (edited)
544
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.71 KB | None | 0 0
  1. import java.util.Locale;
  2. import java.util.Scanner;
  3.  
  4. public class FuelTank {
  5.  
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         String fuelType = scanner.nextLine().toLowerCase(Locale.ROOT);
  10.         int fuelsAvailable = Integer.parseInt(scanner.nextLine());
  11.  
  12.         if (fuelType.equals("diesel") || fuelType.equals("gasoline") || fuelType.equals("gas")) {
  13.             if (fuelsAvailable < 25) {
  14.                 System.out.printf("Fill your tank with %s!", fuelType);
  15.             } else {
  16.                 System.out.printf("You have enough %s.", fuelType);
  17.             }
  18.         } else {
  19.             System.out.println("Invalid fuel!");
  20.         }
  21.  
  22.     }
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement