Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class FuelTank_07 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String fuel = scanner.nextLine().toLowerCase();
- int liters = Integer.parseInt(scanner.nextLine());
- // "Diesel", "Gasoline" или "Gas"
- // са повече или равни на 25 - You have enough
- // са по-малко от 25 - fill your tank
- switch (fuel) {
- case ("gasoline"):
- case ("diesel"):
- case ("gas"):
- if (liters >= 25) {
- System.out.printf("You have enough %s.", fuel);
- } else {
- System.out.printf( "Fill your tank with %s!",fuel);
- } break;
- default :
- System.out.println("Invalid fuel!");
- }
- }
- }
Add Comment
Please, Sign In to add comment