004-007-001

配列の要素数:ポイント記録数

初級

問題説明

配列の要素数:ポイント記録数

学習目標: 配列の.lengthプロパティでデータ件数を取得できる

この問題では: 複数のポイント獲得記録を配列に格納し、.lengthプロパティで件数を取得して一覧表示と集計結果を標準出力に表示するプログラムを作成します。

ポイントカードの獲得記録を管理します。今月のポイント獲得履歴を配列に格納し、.lengthプロパティを使って記録件数を表示します。

入力

1行目: 記録件数n(1~5)
2行目以降: 各回のポイント数(n個、1~100)

出力

=== Point Records ===
Total Records: [n]件
━━━━━━━━━━━━━━━━
[1] [ポイント1]pt
[2] [ポイント2]pt
...
━━━━━━━━━━━━━━━━
Summary: [n]件の記録、合計[合計]pt

具体例

例1: 3件のポイント記録

入力:

3
50
30
20

出力:

=== Point Records ===
Total Records: 3件
━━━━━━━━━━━━━━━━
[1] 50pt
[2] 30pt
[3] 20pt
━━━━━━━━━━━━━━━━
Summary: 3件の記録、合計100pt

テストケース例

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

正常系
入力:
5
15
25
35
45
55
期待される出力:
=== Point Records ===
Total Records: 5 items
━━━━━━━━━━━━━━━━
[1] 15pt
[2] 25pt
[3] 35pt
[4] 45pt
[5] 55pt
━━━━━━━━━━━━━━━━
Summary: 5 records, total 175pt
正常系
入力:
2
40
60
期待される出力:
=== Point Records ===
Total Records: 2 items
━━━━━━━━━━━━━━━━
[1] 40pt
[2] 60pt
━━━━━━━━━━━━━━━━
Summary: 2 records, total 100pt

あなたの解答

現在のモード: 自分のコード
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

残り 10 回実行可能