Advertisement
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);
- int kidsWeekdayPrice = 12;
- int kidsWeekendPrice = 15;
- int kidsHolidayPrice = 5;
- int adultWeekdayPrice = 18;
- int adultWeekendPrice = 20;
- int adultHolidayPrice = 12;
- int oldWeekdayPrice = 12;
- int oldWeekendPrice = 15;
- int oldHolidayPrice = 10;
- String typeOfDay = scanner.nextLine();
- int age = Integer.parseInt(scanner.nextLine());
- if (age < 0 ){
- System.out.println("Error!");
- return;
- }
- switch (typeOfDay){
- case "Weekday":
- if (age <= 18){
- System.out.println(String.format("%d$",kidsWeekdayPrice));
- }else if (age <= 64){
- System.out.println(String.format("%d$",adultWeekdayPrice));
- }else if (age <= 122){
- System.out.println(String.format("%d$",oldWeekdayPrice));
- }
- break;
- case "Weekend":
- if (age <= 18){
- System.out.println(String.format("%d$",kidsWeekendPrice));
- }else if (age <= 64){
- System.out.println(String.format("%d$",adultWeekendPrice));
- }else if (age <= 122){
- System.out.println(String.format("%d$",oldWeekendPrice));
- }
- break;
- case "Holiday":
- if (age <= 18){
- System.out.println(String.format("%d$",kidsHolidayPrice));
- }else if (age <= 64){
- System.out.println(String.format("%d$",adultHolidayPrice));
- }else if (age <= 122){
- System.out.println(String.format("%d$",oldHolidayPrice));
- }
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement