004-007-001

Array Length: Point Records Count

Easy

Problem Description

Array Length: Point Records Count

Learning Objective: Get data count using array's .length property

Manage point card earning records. Store this month's point earning history in an array and display record count using .length property.

Input

Line 1: Number of records n (1-5)
Following lines: Points for each transaction (n items, 1-100)

Output

=== Point Records ===
Total Records: [n] items
━━━━━━━━━━━━━━━━
[1] [points1]pt
[2] [points2]pt
...
━━━━━━━━━━━━━━━━
Summary: [n] records, total [total]pt
```java

## Examples

### Example 1: 3 Point Records
Input:
```java
3
50
30
20
```java
Output:
```java
=== Point Records ===
Total Records: 3 items
━━━━━━━━━━━━━━━━
[1] 50pt
[2] 30pt
[3] 20pt
━━━━━━━━━━━━━━━━
Summary: 3 records, total 100pt

Test Cases

※ Output examples follow programming industry standards

Input:
3
50
30
20
Expected Output:
=== Point Records ===
Total Records: 3 items
━━━━━━━━━━━━━━━━
[1] 50pt
[2] 30pt
[3] 20pt
━━━━━━━━━━━━━━━━
Summary: 3 records, total 100pt
Input:
2
40
60
Expected Output:
=== Point Records ===
Total Records: 2 items
━━━━━━━━━━━━━━━━
[1] 40pt
[2] 60pt
━━━━━━━━━━━━━━━━
Summary: 2 records, total 100pt
Input:
1
100
Expected Output:
=== Point Records ===
Total Records: 1 items
━━━━━━━━━━━━━━━━
[1] 100pt
━━━━━━━━━━━━━━━━
Summary: 1 records, total 100pt
❌ Some tests failed
❌ エラー発生

Your Solution

Current Mode: My Code
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// レコード数を読む
int n = sc.nextInt();
// 複数の値を格納する配列を作成
int[] points = new int[n];
for (int i = 0; i < n; i++) {
points[i] = sc.nextInt();
}
// 計算結果をコンソール出力に表示
System.out.println("=== Point Records ===");
System.out.println("Total Records: " + points.length + " items");
System.out.println("━━━━━━━━━━━━━━━━");
// すべて recordsを表示
for (int i = 0; i < points.length; i++) {
System.out.println("[" + (i + 1) + "] " + points[i] + "pt");
}
// 適切な計算式を使用して結果を計算する
int total = 0;
for (int i = 0; i < points.length; i++) {
total += points[i];
}
System.out.println("━━━━━━━━━━━━━━━━");
System.out.println("Summary: " + points.length + " records, total " + total + "pt");
}
}

0 B / 5 MB

You have 10 free executions remaining