Advertisement
CoineTre

JF-Lab07. Theatre Promotion

Jan 14th, 2021
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.62 KB | None | 0 0
  1. package fundamentals.basics;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class TheatrePromotion {
  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.        int price;
  11.         switch(day){
  12.             case"Weekday":
  13.               if (0 <= age && age <= 18 ){
  14.                     price = 12;
  15.                 }else if(18 < age && age <= 64){
  16.                     price = 18;
  17.                 }else if (64 < age && age <= 122){
  18.                     price = 12;
  19.                 }else{
  20.                   price = -1;
  21.               }
  22.                 break;
  23.             case"Weekend":
  24.                if(0 <= age && age <= 18 ){
  25.                     price = 15;
  26.                 }else if (18 < age && age <= 64){
  27.                     price = 20;
  28.                 }else if(64 < age && age <= 122) {
  29.                     price = 15;
  30.                 }else {
  31.                    price = -1;
  32.                }
  33.                 break;
  34.             case"Holiday":
  35.                 if (0 <= age && age <= 18 ){
  36.                     price = 5;
  37.                 }else if(18 < age && age <= 64){
  38.                     price = 12;
  39.                 }else if (64 < age && age <= 122){
  40.                     price = 10;
  41.                 }else{
  42.                     price = -1;
  43.                 }
  44.                 break;
  45.             default:
  46.                 price = -1;
  47.         }
  48.         if(price != -1) {
  49.             System.out.println(price + "$");
  50.         }else{
  51.             System.out.println("Error!");
  52.         }
  53.     }
  54. }
  55.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement