Advertisement
Spocoman

07. Fuel Tank

Aug 24th, 2024
54
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.Objects;
  2. import java.util.Scanner;
  3.  
  4. public class FuelTank {
  5.     public static void main(String[] args) {
  6.         Scanner scanner = new Scanner(System.in);
  7.         String fuel = scanner.nextLine();
  8.         double liters = Double.parseDouble(scanner.nextLine());
  9.        
  10.         if (Objects.equals(fuel, "Diesel")
  11.                 || Objects.equals(fuel, "Gasoline")
  12.                 || Objects.equals(fuel, "Gas")) {
  13.             if (liters >= 25) {
  14.                 System.out.printf("You have enough %s.\n", fuel.toLowerCase());
  15.             } else {
  16.                 System.out.printf("Fill your tank with %s!\n", fuel.toLowerCase());
  17.             }
  18.         } else {
  19.             System.out.println("Invalid fuel!");
  20.         }
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement