Advertisement
veronikaaa86

07. Theatre Promotion

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