Advertisement
elvirynwa

Theatre Promotion

Jan 29th, 2019
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.97 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class TheatrePromotion {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int kidsWeekdayPrice = 12;
  8.         int kidsWeekendPrice = 15;
  9.         int kidsHolidayPrice = 5;
  10.  
  11.         int adultWeekdayPrice = 18;
  12.         int adultWeekendPrice = 20;
  13.         int adultHolidayPrice = 12;
  14.  
  15.         int oldWeekdayPrice = 12;
  16.         int oldWeekendPrice = 15;
  17.         int oldHolidayPrice = 10;
  18.  
  19.         String typeOfDay = scanner.nextLine();
  20.         int age = Integer.parseInt(scanner.nextLine());
  21.  
  22.         if (age < 0 ){
  23.             System.out.println("Error!");
  24.             return;
  25.         }
  26.  
  27.         switch (typeOfDay){
  28.  
  29.             case "Weekday":
  30.                 if (age <= 18){
  31.                     System.out.println(String.format("%d$",kidsWeekdayPrice));
  32.                 }else if (age <= 64){
  33.                     System.out.println(String.format("%d$",adultWeekdayPrice));
  34.                 }else if (age <= 122){
  35.                     System.out.println(String.format("%d$",oldWeekdayPrice));
  36.                 }
  37.                 break;
  38.             case "Weekend":
  39.                 if (age <= 18){
  40.                     System.out.println(String.format("%d$",kidsWeekendPrice));
  41.                 }else if (age <= 64){
  42.                     System.out.println(String.format("%d$",adultWeekendPrice));
  43.                 }else if (age <= 122){
  44.                     System.out.println(String.format("%d$",oldWeekendPrice));
  45.                 }
  46.                 break;
  47.             case "Holiday":
  48.                 if (age <= 18){
  49.                     System.out.println(String.format("%d$",kidsHolidayPrice));
  50.                 }else if (age <= 64){
  51.                     System.out.println(String.format("%d$",adultHolidayPrice));
  52.                 }else if (age <= 122){
  53.                     System.out.println(String.format("%d$",oldHolidayPrice));
  54.                 }
  55.                 break;
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement