004-007-005

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

初級

問題説明

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

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

この問題では: 標準入力から料理レシピのステップを文字列配列に読み込み、.lengthプロパティでステップ数を取得して整形出力するプログラムを作成します。

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

入力

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

出力

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

具体例

例1: 3ステップのレシピ

入力:

3
材料を切る
鍋で煮る
盛り付ける

出力:

=== Recipe Steps ===
Total Steps: 3個
━━━━━━━━━━━━━━━━
Step 1: 材料を切る
Step 2: 鍋で煮る
Step 3: 盛り付ける
━━━━━━━━━━━━━━━━
All 3 steps loaded!

テストケース例

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

入力:
3
Cut ingredients
Boil in hot pot
Serve
期待される出力:
=== Recipe Steps ===
Total Steps: 3 items
━━━━━━━━━━━━━━━━
Step 1: Cut ingredients
Step 2: Boil in hot pot
Step 3: Serve
━━━━━━━━━━━━━━━━
All 3 steps loaded!
入力:
2
Heat frying pan
Fry eggs
期待される出力:
=== Recipe Steps ===
Total Steps: 2 items
━━━━━━━━━━━━━━━━
Step 1: Heat frying pan
Step 2: Fry eggs
━━━━━━━━━━━━━━━━
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 回実行可能