007-004-001
Class Aggregation: Inventory List
Easy
Problem Description
class Aggregation: Inventory List
In this problem, you will create a program that defines a Product class, manages its objects in an array, reads product names and stock counts from standard input, and displays inventory information to standard output.
Learning Objective: Manage multiple objects in an array
Define a Product class with a product name field (String) and a stock count field (int), store the objects in an array, and display the inventory information.
Input
Line 1: Product count (integer)
Line 2 onwards: Product name and stock (string and integer, multiple lines)
Output
[name1]: [stock1] items
[name2]: [stock2] items
...
```java
## Examples
### Example 1: 2 products inventory
Input:
```java
2
Notebook 50
Pencil 100
```java
Output:
```java
Notebook: 50 items
Pencil: 100 items
```java
### Example 2: 3 products inventory
Input:
```java
3
A 10
B 20
C 30
```java
Output:
```java
A: 10 items
B: 20 items
C: 30 items
```java
### Example 3: 1 product (boundary)
Input:
```java
1
X 0
```java
Output:
```java
X: 0 items
Test Cases
※ Output examples follow programming industry standards
Normal case
Input:
4 Apple 30 Banana 15 Cherry 8 Mango 42
Expected Output:
Apple: 30 items Banana: 15 items Cherry: 8 items Mango: 42 items
Normal case
Input:
3 Desk 5 Chair 12 Lamp 7
Expected Output:
Desk: 5 items Chair: 12 items Lamp: 7 items
Your Solution
Current Mode:● My Code
Product.java🔒
Solution.java🔒
2/6 ファイル96B
⚠️警告
- No main method found
9
1
2
3
4
›
⌄
import java.util.Scanner;
class Product {
}
0 B / 5 MB
You have 10 free executions remaining
