desislava_topuzakova

07. Theatre Promotion

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