List Management: Shopping List
Problem Description
List Management: Shopping List
In this problem, you will create a program that reads product names from standard input, stores them in an ArrayList, displays each item with a numbered label, and outputs the total count to standard output.
Learning Objective: Use ArrayList to manage multiple data and learn basic operations of add, get, and size
Read the number of products and each product name from standard input, storing them in an ArrayList<String> using add(). Then iterate over the list with a for loop, retrieving each element via get(i) to display it in [1] product name format, and finally output the total item count using size().
Input
Line 1: Number of products (integer, 1-10 items)
Lines 2~N+1: Product name (string)
Output
Shopping List:
[1] [product name 1]
[2] [product name 2]
...
Total Items: [number of products]
Test Cases
※ Output examples follow programming industry standards
3 Milk Bread Eggs
Shopping List: [1] Milk [2] Bread [3] Eggs Total Items: 3
5 Apple Banana Orange Grapes Watermelon
Shopping List: [1] Apple [2] Banana [3] Orange [4] Grapes [5] Watermelon Total Items: 5
Your Solution
You have 10 free executions remaining
