Didart

Theatre Promotion

Sep 16th, 2021
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.28 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class TheatrePromotions {
  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.         if (day.equals("Weekday")) {
  12.             if (age >= 0 && age <= 18) {
  13.                 price = 12;
  14.             } else if (age > 18 && age <= 64) {
  15.                 price = 18;
  16.             } else if (age > 64 && age <= 122) {
  17.                 price = 12;
  18.             }
  19.         } else if (day.equals("Weekend")) {
  20.             if (age >= 0 && age <= 18) {
  21.                 price = 15;
  22.             } else if (age > 18 && age <= 64) {
  23.                 price = 20;
  24.             } else if (age > 64 && age <= 122) {
  25.                 price = 15;
  26.             }
  27.         } else if (day.equals("Holiday")) {
  28.             if (age >= 0 && age <= 18) {
  29.                 price = 5;
  30.             } else if (age > 18 && age <= 64) {
  31.                 price = 12;
  32.             } else if (age > 64 && age <= 122) {
  33.                 price = 10;
  34.             }
  35.         }
  36.         if (price > 0) {
  37.             System.out.println(price + "$");
  38.         } else {
  39.             System.out.println("Error!");
  40.         }
  41.  
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment