Advertisement
veronikaaa86

07. Theatre Promotion

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