020-003-001

Map Management: Product Price List

Easy

Problem Description

Map Management: Product Price List

In this problem, you will create a program that uses LinkedHashMap to store product names and prices in insertion order, and displays a price list with the total amount to standard output.

Learning Objective: Use key-value pairs with LinkedHashMap to manage correspondence between product names and prices

Create a price list program that manages product names and their prices. Declare a LinkedHashMap<String, Integer> and register each product using put(productName, price). After all products are registered, iterate through entries with entrySet() to display them in insertion order, then use values() to retrieve all prices and calculate the total amount.

Input

Line 1: Number of products (integer, 1-10 items)
Lines 2~N+1: Product name and price (space-separated)

Output

Price List:
[product name 1]: [price 1]yen
[product name 2]: [price 2]yen
...
Total: [total amount]yen
```java

Products displayed in registration order.

Test Cases

※ Output examples follow programming industry standards

Normal case
Input:
3
Apple 150
Banana 100
Orange 200
Expected Output:
Price List:
Apple: 150yen
Banana: 100yen
Orange: 200yen
Total: 450yen
Normal case
Input:
5
Milk 180
Bread 120
Eggs 200
Cheese 350
Butter 280
Expected Output:
Price List:
Milk: 180yen
Bread: 120yen
Eggs: 200yen
Cheese: 350yen
Butter: 280yen
Total: 1130yen

Your Solution

Current Mode: My Code
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Write your code here

sc.close();
}
}
0 B / 5 MB

You have 10 free executions remaining