005-003-001
Nested If: Parking Fee
Easy
Problem Description
Nested If: Parking Fee
In this problem, you will create a program that reads parking hours and a membership flag, calculates the parking fee using nested if statements based on the combination of membership status and parking duration, and displays the result to standard output.
Learning Objective: Judge multiple conditions with nested if statements
Create a program that inputs parking hours and membership status to determine the fee. Learn the nested structure by first checking membership, then checking time within that block.
Rules:
- Member: 500 yen for 3+ hours, 300 yen under 3 hours
- Non-member: 1000 yen for 3+ hours, 600 yen under 3 hours
Input
Line 1: Parking hours (integer)
Line 2: Member flag (true=member, false=non-member)
Output
Parking hours: [hours] hours
Member: [status]
Fee: [fee] yen
Examples
Example 1: Member with 3+ hours
Input:
4
true
Output:
Parking hours: 4 hours
Member: true
Fee: 500 yen
Example 2: Member under 3 hours
Input:
2
true
Output:
Parking hours: 2 hours
Member: true
Fee: 300 yen
Test Cases
※ Output examples follow programming industry standards
Normal case
Input:
5 true
Expected Output:
Parking hours: 5 hours Member: true Fee: 500 yen
Normal case
Input:
2 false
Expected Output:
Parking hours: 2 hours Member: false Fee: 600 yen
Your Solution
Current Mode:● My Code
99
1
2
3
4
5
6
7
8
9
10
›
⌄
⌄
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
