A_Marinov

Untitled

Apr 27th, 2020
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.05 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class FuleTank {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.         String fuelType = scan.nextLine();
  7.         int liters = Integer.parseInt(scan.nextLine());
  8.         if (fuelType.equals("Diesel")) {
  9.             if (liters >= 25)
  10.                 System.out.println("You have enough diesel.");
  11.             else System.out.println("Fill your tank with diesel!");
  12.         }
  13.         if (fuelType.equals("Gasoline")) {
  14.             if (liters >= 25)
  15.                 System.out.println("You have enough gasoline.");
  16.             else System.out.println("Fill your tank with gasoline!");
  17.         }
  18.         if (fuelType.equals("Gas")) {
  19.             if (liters >= 25)
  20.                 System.out.println("You have enough gas.");
  21.             else System.out.println("Fill you tank with gas!");
  22.         }
  23.         if (!fuelType.equals("Diesel") && (!fuelType.equals("Gasoline") && (!fuelType.equals("Gas")))) {
  24.             System.out.println("Invalid fuel!");
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment