Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Theatre {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String day = scanner.nextLine().toLowerCase();
- int age = scanner.nextInt();
- double price = 0.0;
- boolean isValid = true;
- if (day.equals("weekday")) {
- if (age >= 0 && age <= 18) {
- price = 12;
- } else if (age > 18 && age <= 64) {
- price = 18;
- } else if (age > 64 && age <= 122) {
- price = 12;
- }
- } else if (day.equals("weekend")) {
- if (age >= 0 && age <= 18) {
- price = 15;
- } else if (age > 18 && age <= 64) {
- price = 20;
- } else if (age > 64 && age <= 122) {
- price = 15;
- }
- } else if (day.equals("holiday")) {
- if (age >= 0 && age <= 18) {
- price = 5;
- } else if (age > 18 && age <= 64) {
- price = 12;
- } else if (age > 64 && age <= 122) {
- price = 10;
- }
- } else {
- isValid = false;
- }
- if (isValid) {
- System.out.printf("%.0f$", price);
- } else {
- System.out.println("Error!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement