SotirovG

Fueltank_07

Sep 22nd, 2020 (edited)
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.91 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class FuelTank_07 {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         String fuel = scanner.nextLine().toLowerCase();
  8.         int liters = Integer.parseInt(scanner.nextLine());
  9.         // "Diesel", "Gasoline" или "Gas"
  10.         // са повече или равни на 25 - You have enough
  11.         // са по-малко от 25 - fill your tank
  12.  
  13.         switch (fuel) {
  14.                 case ("gasoline"):
  15.                     case ("diesel"):
  16.                         case ("gas"):
  17.                 if (liters >= 25) {
  18.                     System.out.printf("You have enough %s.", fuel);
  19.                 } else {
  20.                     System.out.printf( "Fill your tank with %s!",fuel);
  21.                 } break;
  22.             default :
  23.                 System.out.println("Invalid fuel!");
  24.  
  25.  
  26.  
  27.  
  28.  
  29.         }
  30.     }
  31. }
  32.  
Add Comment
Please, Sign In to add comment