005-003-002

Nested If: Ticket Price

Easy

Problem Description

Nested If: Ticket Price

In this problem, you will create a program that receives age and student status as input, applies nested if statements to determine the ticket price based on multiple conditions, and displays the result to standard output.

Learning Objective: Judge multiple conditions with nested if statements

Create a program that inputs age and student status to determine the ticket price. Learn the nested structure by first checking age, then checking student status within that branch.

Rules:

  • 18+: 1500 yen for students, 2000 yen for general
  • Under 18: 1000 yen for students, 1200 yen for general

Input

Line 1: Age (integer)
Line 2: Student flag (true=student, false=general)

Output

Age: [age] years old
Student: [status]
Ticket price: [price] yen

Examples

Example 1: Adult student

Input:

20
true

Output:

Age: 20 years old
Student: true
Ticket price: 1500 yen

Example 2: Minor general

Input:

15
false

Output:

Age: 15 years old
Student: false
Ticket price: 1200 yen

Test Cases

※ Output examples follow programming industry standards

Normal case
Input:
12
false
Expected Output:
Age: 12 years old
Student: false
Ticket price: 1200 yen
Normal case
Input:
25
false
Expected Output:
Age: 25 years old
Student: false
Ticket price: 2000 yen

Your Solution

Current Mode: My Code
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Write your code here

sc.close();
}
}
0 B / 5 MB

You have 10 free executions remaining