020-003-005

Map Management: Phonebook

Easy

Problem Description

Map Management: Phonebook

Learning Objective: Manage key-value pairs with LinkedHashMap, perform data storage, retrieval, and listing

HashMap is data structure storing "key (identifier) and value (data)" pairs. Like phonebook, can manage relationships like "name → phone number". Add pairs with put() method, retrieve corresponding value from key with get() method. Check key existence with containsKey().

Input

Line 1: Number of registrations (integer, 1-10 people)
Lines 2~N+1: Name and phone number (space-separated)

Output

Phonebook:
[name 1]: [phone number 1]
[name 2]: [phone number 2]
...
Total Contacts: [registration count]
```java

Contacts displayed in registration order.

Test Cases

※ Output examples follow programming industry standards

Input:
3
Alice 080-1234-5678
Bob 090-8765-4321
Charlie 070-1111-2222
Expected Output:
Phonebook:
Alice: 080-1234-5678
Bob: 090-8765-4321
Charlie: 070-1111-2222
Total Contacts: 3
Input:
5
David 080-2222-3333
Emily 090-4444-5555
Frank 070-6666-7777
Grace 080-8888-9999
Henry 090-0000-1111
Expected Output:
Phonebook:
David: 080-2222-3333
Emily: 090-4444-5555
Frank: 070-6666-7777
Grace: 080-8888-9999
Henry: 090-0000-1111
Total Contacts: 5
Input:
1
Ivy 080-5555-6666
Expected Output:
Phonebook:
Ivy: 080-5555-6666
Total Contacts: 1
Input:
4
Jack 090-1111-2222
Kate 080-3333-4444
Leo 070-5555-6666
Mia 090-7777-8888
Expected Output:
Phonebook:
Jack: 090-1111-2222
Kate: 080-3333-4444
Leo: 070-5555-6666
Mia: 090-7777-8888
Total Contacts: 4
❌ Some tests failed
❌ エラー発生

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 9 free executions remaining