Advertisement
Spocoman

07. Theatre Promotion

Oct 16th, 2024 (edited)
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.69 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. class TheatrePromotion {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         String day = scanner.nextLine();
  7.         int age = Integer.parseInt(scanner.nextLine()),
  8.                 sum = 0;
  9.  
  10.         if (age >= 0 && age < 123) {
  11.             sum = switch (day) {
  12.                 case "Weekday" -> age > 18 && age <= 64 ? 18 : 12;
  13.                 case "Weekend" -> age > 18 && age <= 64 ? 20 : 15;
  14.                 case "Holiday" -> age <= 18 ? 5 : age > 64 ? 10 : 12;
  15.                 default -> sum;
  16.             };
  17.         }
  18.  
  19.         System.out.println(sum == 0 ? "Error!" : String.format("%d$", sum));
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement