Guest User

Untitled

a guest
Mar 14th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. public class Program {
  2.  
  3. public static void main(String[] args) {
  4.  
  5. HashMap<String, Integer> species = new HashMap<>();
  6. Scanner reader = new Scanner(System.in);
  7.  
  8. species.put("hawk (buteo jamaicensis)", 0);
  9. species.put("eagle (aquila chrysaetos)", 0);
  10. species.put("sparrow (passeridae)", 0);
  11.  
  12. System.out.println("Add perception");
  13. System.out.println("What was perceived?"); //output should be "hawk"/"eagle"/"sparrow"
  14. String perception = reader.nextLine();
  15.  
  16. // Change here the value of hashmap key.
  17.  
  18. ArrayList<String> list = new ArrayList<>();
  19. for (HashMap.Entry<String, Integer> entry: species.entrySet()) {
  20. System.out.println((entry.getKey()+" : "+entry.getValue()+" perception"));
  21. }
  22.  
  23.  
  24.  
  25. }
  26.  
  27. sparrow (passeridae) : 0 perception
  28. eagle (aquila chrysaetos) : 0 perception
  29. hawk (buteo jamaicensis) : 1 perception
Add Comment
Please, Sign In to add comment