1 package com.mieba.notebook;
2
3 import java.util.HashMap;
4 import java.util.Scanner;
5
6
7
8 public class Coin//美元硬币检索
9 {
10 private HashMap<Integer, String> coinnames=new HashMap<Integer, String>();
11
12 public Coin()
13 {
14 coinnames.put(1, "penny");
15 coinnames.put(10, "dime");
16 coinnames.put(25, "quarter");
17 coinnames.put(50, "half—dollar");
18 }
19
20 public String getName(int amount)
21 {
22 if (coinnames.containsKey(amount))
23 {
24 return coinnames.get(amount);
25
26 } else
27 {
28 return "NOT FOUND";
29
30 }
31 }
32
33 public void list()
34 {
35 for (Integer k : coinnames.keySet())
36 {
37 String s=coinnames.get(k);
38 System.out.println(s);
39 }
40 }
41
42 public static void main(String[] args)
43 {
44 Scanner cin=new Scanner(System.in);
45 int amount = cin.nextInt();
46 Coin coin=new Coin();
47 System.out.println(coin.getName(amount));
48 coin.list();
49
50 }
51 }