Didart

Theatre Promotion

Sep 24th, 2021
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.37 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.         String dayType = scanner.nextLine();
  8.         int personAge = Integer.parseInt(scanner.nextLine());
  9.         double ticketPrice = 0;
  10.         if (dayType.equals("Weekday")) {
  11.             if ((personAge >= 0 && personAge <= 18) || (personAge > 64 && personAge <= 122)) {
  12.                 ticketPrice = 12;
  13.             } else if (personAge > 18 && personAge <= 64) {
  14.                 ticketPrice = 18;
  15.             }
  16.         } else if (dayType.equals("Weekend")) {
  17.             if ((personAge >= 0 && personAge <= 18) || (personAge > 64 && personAge <= 122)) {
  18.                 ticketPrice = 15;
  19.             } else if (personAge > 18 && personAge <= 64) {
  20.                 ticketPrice = 20;
  21.             }
  22.         } else if (dayType.equals("Holiday")) {
  23.             if (personAge >= 0 && personAge <= 18) {
  24.                 ticketPrice = 5;
  25.             } else if (personAge > 18 && personAge <= 64) {
  26.                 ticketPrice = 12;
  27.             } else if (personAge > 64 && personAge <= 122) {
  28.                 ticketPrice = 10;
  29.             }
  30.         }
  31.         if (ticketPrice != 0) {
  32.             System.out.printf("%.0f$", ticketPrice);
  33.         } else {
  34.             System.out.println("Error!");
  35.         }
  36.     }
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment