Advertisement
veronikaaa86

07. Theatre Promotion

Sep 14th, 2022
988
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.54 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 day = scanner.nextLine();
  10.         int age = Integer.parseInt(scanner.nextLine());
  11.  
  12.         int price = 0;
  13.         boolean isValid = true;
  14.         if (age >= 0 && age <= 18) {
  15.             if (day.equals("Weekday")) {
  16.                 price = 12;
  17.             } else if (day.equals("Weekend")) {
  18.                 price = 15;
  19.             } else if (day.equals("Holiday")) {
  20.                 price = 5;
  21.             } else {
  22.                 isValid = false;
  23.             }
  24.         } else if (age > 18 && age <= 64) {
  25.             if (day.equals("Weekday")) {
  26.                 price = 18;
  27.             } else if (day.equals("Weekend")) {
  28.                 price = 20;
  29.             } else if (day.equals("Holiday")) {
  30.                 price = 12;
  31.             } else {
  32.                 isValid = false;
  33.             }
  34.         } else if (age > 64 && age <= 122) {
  35.             if (day.equals("Weekday")) {
  36.                 price = 12;
  37.             } else if (day.equals("Weekend")) {
  38.                 price = 15;
  39.             } else if (day.equals("Holiday")) {
  40.                 price = 10;
  41.             } else {
  42.                 isValid = false;
  43.             }
  44.         } else {
  45.             isValid = false;
  46.         }
  47.  
  48.         if (!isValid) {
  49.             System.out.println("Error!");
  50.         } else {
  51.             System.out.printf("%d$", price);
  52.         }
  53.     }
  54. }
  55.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement