Advertisement
myrdok123

07. Theatre Promotion

May 15th, 2024
705
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.35 KB | None | 0 0
  1. package ProgramingBasicsOverview;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P07_TheatrePromotions {
  6.  
  7.     public static void main(String[] args) {
  8.  
  9.  
  10.         Scanner scanner = new Scanner(System.in);
  11.  
  12.         String dayType = scanner.nextLine();
  13.         int age = Integer.parseInt(scanner.nextLine());
  14.  
  15.         double price = 0;
  16.         switch (dayType) {
  17.             case "Weekday" -> {
  18.                 if ((age >= 0 && age <= 18) || (age > 64 && age <= 122)) {
  19.                     price = 12;
  20.                 } else if (age > 18 && age <= 64) {
  21.                     price = 18;
  22.                 }
  23.             }
  24.             case "Weekend" -> {
  25.                 if ((age >= 0 && age <= 18) || (age > 64 && age <= 122)) {
  26.                     price = 15;
  27.                 } else if (age > 18 && age <= 64) {
  28.                     price = 20;
  29.                 }
  30.             }
  31.             case "Holiday" -> {
  32.  
  33.                 if (age >= 0 && age <= 18) {
  34.                     price = 5;
  35.                 } else if (age > 18 && age <= 64) {
  36.                     price = 12;
  37.                 } else if (age > 64 && age <= 122) {
  38.                     price = 10;
  39.                 }
  40.             }
  41.         }
  42.  
  43.         if(price != 0){
  44.             System.out.printf("%.0f$", price);
  45.         }else {
  46.             System.out.println("Error!");
  47.         }
  48.     }
  49. }
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement