Advertisement
CR7CR7

TheatrePromotion

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