007-004-006

Class Aggregation: Inventory List

Easy

Problem Description

class Aggregation: Inventory List

In this problem, you will create a program that defines a Product class, stores multiple product inventory objects in an array, and displays the inventory information to standard output.

Learning Objective: Manage multiple objects in array

Define a Product class with fields for product name (String) and stock count (int). Read each product's data from input, instantiate a Product object for each entry, and store them in an array. Then iterate through the array in order and print each product's inventory in the specified format.

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

Ready to Try Running Code?

Log in to access the code editor and execute your solutions for this problem.

Don't have an account?

Sign Up