Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Program {
- public static void main(String[] args) {
- HashMap<String, Integer> species = new HashMap<>();
- Scanner reader = new Scanner(System.in);
- species.put("hawk (buteo jamaicensis)", 0);
- species.put("eagle (aquila chrysaetos)", 0);
- species.put("sparrow (passeridae)", 0);
- System.out.println("Add perception");
- System.out.println("What was perceived?"); //output should be "hawk"/"eagle"/"sparrow"
- String perception = reader.nextLine();
- // Change here the value of hashmap key.
- ArrayList<String> list = new ArrayList<>();
- for (HashMap.Entry<String, Integer> entry: species.entrySet()) {
- System.out.println((entry.getKey()+" : "+entry.getValue()+" perception"));
- }
- }
- sparrow (passeridae) : 0 perception
- eagle (aquila chrysaetos) : 0 perception
- hawk (buteo jamaicensis) : 1 perception
Add Comment
Please, Sign In to add comment