In: Computer Science
You have been working with the arrays for the past few weeks and you have learned their limitations.
In this assignment, you will be using a new data structure, HashMaps, to repeat Assignment 8.3.
Main Method
Sample Run: For the below input:
1 120000 6 2 50000 25 3 140000 4 4 112000 22 5 130000 4 -1
The output will be:
You added 5 employees! Thank you! Monthly payment for employee 1 is calculated. Monthly payment for employee 2 is calculated. Monthly payment for employee 3 is calculated. Monthly payment for employee 4 is calculated. Monthly payment for employee 5 is calculated. A payment of 10000 was made to employee 1. A payment of 11666 was made to employee 3. A payment of 10833 was made to employee 5.
HashMap is a Map based collection class that is
used for storing Key & value pairs, it is denoted as
HashMap<Key, Value> or
HashMap<K, V>.
Items can be added to HashMap by using put() method as
map.put(key,value). We can access a value of
HashMap by get() method as map.get(key). We can
remove an item from HashMap using remove() method as
map.remove(key). (Assumed map is a HashMap
Object).
Output: