Untitled

mail@pastecode.io avatar
unknown
java
2 years ago
1.6 kB
4
Indexable
Never
package ConditionalsAdvancedExercise;

import java.util.Scanner;

public class Z {
    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);

        String typeDay = scan.nextLine();
        int age = Integer.parseInt(scan.nextLine());

        int price = 0;

        if (0 <= age && age <= 18) {
            switch (typeDay) {
                case "Weekday":
                    price = 12;
                    break;

                case "Weekend":
                    price = 15;
                    break;

                case "Holiday":
                    price = 5;
                    break;
            }

        } else if (18 < age && age <= 64) {
            switch (typeDay) {
                case "Weekday":
                    price = 18;
                    break;

                case "Weekend":
                    price = 20;
                    break;

                case "Holiday":
                    price = 12;
                    break;
            }

        } else if (64 < age && age <= 122) {
            switch (typeDay) {
                case "Weekday":
                    price = 12;
                    break;

                case "Weekend":
                    price = 15;
                    break;

                case "Holiday":
                    price = 10;
                    break;
            }

        }

        if (age >= 0) {
            System.out.printf("%d$", price);
        } else if (age < 0) {
            System.out.println("Error!");
        }
    }
}