004-007-005
Array Length: Recipe Steps Count
Easy
Problem Description
array Length: Recipe Steps Count
Learning Objective: Get element count with String array's length property
In this problem, you will create a program that reads cooking recipe steps from standard input into a String array, retrieves the step count using the .length property, and displays the formatted result to standard output.
Manage cooking recipe steps. Read recipe steps stored in an array and display total step count using .length property.
Input
Line 1: Number of steps n (1-5)
Following lines: Step descriptions (n items)
Output
=== Recipe Steps ===
Total Steps: [n] items
━━━━━━━━━━━━━━━━
Step 1: [step1]
Step 2: [step2]
...
━━━━━━━━━━━━━━━━
All [n] steps loaded!
Examples
Example 1: 3-Step Recipe
Input:
3
Cut ingredients
Boil in pot
Serve
Output:
=== Recipe Steps ===
Total Steps: 3 items
━━━━━━━━━━━━━━━━
Step 1: Cut ingredients
Step 2: Boil in pot
Step 3: Serve
━━━━━━━━━━━━━━━━
All 3 steps loaded!
Test Cases
※ Output examples follow programming industry standards
Input:
3 Cut ingredients Boil in hot pot Serve
Expected Output:
=== Recipe Steps === Total Steps: 3 items ━━━━━━━━━━━━━━━━ Step 1: Cut ingredients Step 2: Boil in hot pot Step 3: Serve ━━━━━━━━━━━━━━━━ All 3 steps loaded!
Input:
2 Heat frying pan Fry eggs
Expected Output:
=== Recipe Steps === Total Steps: 2 items ━━━━━━━━━━━━━━━━ Step 1: Heat frying pan Step 2: Fry eggs ━━━━━━━━━━━━━━━━ All 2 steps loaded!
Input:
1 Complete
Expected Output:
=== Recipe Steps === Total Steps: 1 items ━━━━━━━━━━━━━━━━ Step 1: Complete ━━━━━━━━━━━━━━━━ All 1 steps loaded!
Input:
4 Wash Cut Cook Serve
Expected Output:
=== Recipe Steps === Total Steps: 4 items ━━━━━━━━━━━━━━━━ Step 1: Wash Step 2: Cut Step 3: Cook Step 4: Serve ━━━━━━━━━━━━━━━━ All 4 steps loaded!
❌ Some tests failed
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 9 free executions remaining
