Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package L08_Conditional_Statements_More_Exercises;
- import java.util.Scanner;
- public class Upr08_Fuel_Tank {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String fuel = scanner.nextLine();
- double litres = Double.parseDouble(scanner.nextLine());
- if (!"Diesel".equals(fuel)) {
- if (!"Gasoline".equals(fuel)) {
- if (!"Gas".equals(fuel)) {
- System.out.println("Invalid fuel!");
- }
- }
- }
- if (litres >= 25) {
- if ("Diesel".equals(fuel) || "Gasoline".equals(fuel) || "Gas".equals(fuel)) {
- System.out.printf("You have enough %s.", fuel.toLowerCase());
- }
- }
- if (litres < 25) {
- System.out.printf("Fill your tank with %s!", fuel.toLowerCase());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement