Advertisement
uktcar

02.3.07FuelTankSwitch

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