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
テストケース例
※ 出力例はプログラミングの国際標準に準拠し英語で表示しています
入力:
3 50 30 20
期待される出力:
=== Point Records === Total Records: 3 items ━━━━━━━━━━━━━━━━ [1] 50pt [2] 30pt [3] 20pt ━━━━━━━━━━━━━━━━ Summary: 3 records, total 100pt
入力:
2 40 60
期待される出力:
=== Point Records === Total Records: 2 items ━━━━━━━━━━━━━━━━ [1] 40pt [2] 60pt ━━━━━━━━━━━━━━━━ Summary: 2 records, total 100pt
入力:
1 100
期待される出力:
=== Point Records === Total Records: 1 items ━━━━━━━━━━━━━━━━ [1] 100pt ━━━━━━━━━━━━━━━━ Summary: 1 records, total 100pt
入力:
4 10 20 30 40
期待される出力:
=== Point Records === Total Records: 4 items ━━━━━━━━━━━━━━━━ [1] 10pt [2] 20pt [3] 30pt [4] 40pt ━━━━━━━━━━━━━━━━ Summary: 4 records, total 100pt
❌ テストに失敗したケースがあります
あなたの解答
現在のモード:● 自分のコード
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);
// ここにコードを書いてください
sc.close();
}
}
0 B / 5 MB
残り 9 回実行可能
