Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class TheatrePromotion {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String dayType = scanner.nextLine();
- int personAge = Integer.parseInt(scanner.nextLine());
- double ticketPrice = 0;
- if (dayType.equals("Weekday")) {
- if ((personAge >= 0 && personAge <= 18) || (personAge > 64 && personAge <= 122)) {
- ticketPrice = 12;
- } else if (personAge > 18 && personAge <= 64) {
- ticketPrice = 18;
- }
- } else if (dayType.equals("Weekend")) {
- if ((personAge >= 0 && personAge <= 18) || (personAge > 64 && personAge <= 122)) {
- ticketPrice = 15;
- } else if (personAge > 18 && personAge <= 64) {
- ticketPrice = 20;
- }
- } else if (dayType.equals("Holiday")) {
- if (personAge >= 0 && personAge <= 18) {
- ticketPrice = 5;
- } else if (personAge > 18 && personAge <= 64) {
- ticketPrice = 12;
- } else if (personAge > 64 && personAge <= 122) {
- ticketPrice = 10;
- }
- }
- if (ticketPrice != 0) {
- System.out.printf("%.0f$", ticketPrice);
- } else {
- System.out.println("Error!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment