004-007-002

配列の要素数:レシピステップ数

初級

問題説明

配列の要素数:レシピステップ数

学習目標: 文字列配列のlengthプロパティで要素数を取得できる

この問題では: 標準入力からレシピのステップをString配列に読み込み、.lengthプロパティで要素数を取得して、指定フォーマットで標準出力に表示するプログラムを作成します。

料理レシピの手順を管理します。配列に格納されたレシピのステップを読み取り、.lengthプロパティを使って全体のステップ数を表示します。

入力

1行目: ステップ数n(1~5)
2行目以降: 各ステップの説明(n個)

出力

=== Recipe Steps ===
Total Steps: [n]個
━━━━━━━━━━━━━━━━
Step 1: [ステップ1]
Step 2: [ステップ2]
...
━━━━━━━━━━━━━━━━
All [n] steps loaded!
```java

## 具体例

### 例1: 3ステップのレシピ
入力:
```java
3
材料を切る
鍋で煮る
盛り付ける
```java
出力:
```java
=== Recipe Steps ===
Total Steps: 3個
━━━━━━━━━━━━━━━━
Step 1: 材料を切る
Step 2: 鍋で煮る
Step 3: 盛り付ける
━━━━━━━━━━━━━━━━
All 3 steps loaded!

テストケース例

※ 出力例はプログラミングの国際標準に準拠し英語で表示しています

入力:
3
Cut ingredients
Boil in pot
Plate and serve
期待される出力:
=== Recipe Steps ===
Total Steps: 3 items
━━━━━━━━━━━━━━━━
Step 1: Cut ingredients
Step 2: Boil in pot
Step 3: Plate and serve
━━━━━━━━━━━━━━━━
All 3 steps loaded!
入力:
2
Heat the pan
Fry the egg
期待される出力:
=== Recipe Steps ===
Total Steps: 2 items
━━━━━━━━━━━━━━━━
Step 1: Heat the pan
Step 2: Fry the egg
━━━━━━━━━━━━━━━━
All 2 steps loaded!
入力:
1
Complete
期待される出力:
=== Recipe Steps ===
Total Steps: 1 items
━━━━━━━━━━━━━━━━
Step 1: Complete
━━━━━━━━━━━━━━━━
All 1 steps loaded!
入力:
4
Wash
Cut
Cook
Serve
期待される出力:
=== Recipe Steps ===
Total Steps: 4 items
━━━━━━━━━━━━━━━━
Step 1: Wash
Step 2: Cut
Step 3: Cook
Step 4: Serve
━━━━━━━━━━━━━━━━
All 4 steps loaded!
❌ テストに失敗したケースがあります
❌ エラー発生

あなたの解答

現在のモード: 自分のコード
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// ここにコードを書いてください

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

残り 9 回実行可能