Question

In: Computer Science

You have been working with the arrays for the past few weeks and you have learned...

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

  • (5 points) Declare and initialize an HashMap with values of type of type Employee, and keys of type integer. In a while loop, keep initializing objects of type Employee, storing them in the HashMap, and allow the user to enter ID, salary, and leaveDays of the each employee one by one and in one line. Once the user entered a -1, stop initializing new employees, and print "You entered [actual length of array] employees. Thank you!"
  • (5 points) In a foreach loop, go through every Employee object in the HashMap, and calculate their monthly payments, using the calcMonthlyPayment() method.
  • (10 points) In a second foreach loop, go through every Employee object in the HashMap, and call their makePayment method only if their leaveDays is NOT higher than 21.

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.

Solutions

Expert Solution

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:



Related Solutions

In the past few weeks we have learned that the number of miles driven has fallen...
In the past few weeks we have learned that the number of miles driven has fallen due to people staying at home during the coronavirus pandemic. Insurers are offering auto insurance rebates to policyholders due to the decrease in number of miles driven. New research however indicates that this does not tell the entire driving story. Although miles driven and traffic congestion are falling, both the accident rate and severity of accidents seems to be rising. Please explain what’s happening...
Aligning Performance Appraisals and Compensation Plans During the past few weeks, we have learned that there...
Aligning Performance Appraisals and Compensation Plans During the past few weeks, we have learned that there are various methods of conducting employee performance appraisals (e.g., trait, behavioral, ranking, MBO, etc.). Your task for this assignment is to pick one of those methods, explain it, and discuss how it could be effectively used to impact employee compensation. Your response should consider the potential impact the performance evaluation method could have on at least three different organizational stakeholder groups. Also, your assignment...
For the past few months, you and your new business partner named Offset, have been working...
For the past few months, you and your new business partner named Offset, have been working on a proposal to close a very difficult business deal with a major clothing retailer. You feel he is key to the successful internal operation of the company and you are delighted that he has agreed to come aboard. As your new partner he has several contacts in the industry who have expressed interest in the NOAH clothing line. You recently inherited $1M from...
Over the past few weeks, you have become more familiar with your staff and are beginning...
Over the past few weeks, you have become more familiar with your staff and are beginning to feel like part of their family. To that end, you have recently accepted some "friend requests" on Facebook from some of the staff. You were at home last night, getting caught up on Facebook when you came across a post from one of the employees that said: " I hate my new boss at the clinic. A power hungry jerk making too many...
tax - corporate Review and reflect on what you have learned over the past 8 weeks....
tax - corporate Review and reflect on what you have learned over the past 8 weeks. Identify and discuss what the most practical and easily applied lesson you learned was. also, discuss which lesson was the hardest for you to grasp? why?
In the past two weeks you have learned about the relational data model and hopefully had...
In the past two weeks you have learned about the relational data model and hopefully had some practice creating a normalized relational schema through the use of entity/relationship modeling. Based on what you know, please think about various types of software application. Consider what the databases that back these applications might look like. Describe at least one application--whether already existing or hypothetical--for which you believe the relational model would NOT be a good fit. Explain why. Describe another application--already existing...
During the past weeks, you have been introduced to software development planning techniques and tools. You...
During the past weeks, you have been introduced to software development planning techniques and tools. You have actually gained some experience using a few design techniques and tools in planning to create an application that meets business requirements. A design document was the resultant outcome of your efforts. You have also coded a couple object-oriented programs that meet these planned-for requirements. These tasks have given you a sense of what is required to plan for and to develop applications. In...
Several of our readings in past weeks have been on the effects on health of a...
Several of our readings in past weeks have been on the effects on health of a microbiota shift. One example is the study of malnourished Malawian twins who had developed kwashiorkor. Can Koch's postulates be extended to cover a community of microbes? Explain which of Koch's postulates were fulfilled and which were violated in this study. What experiment(s) did the scientists do to fulfill Koch's third postulate? reference link: http://science.sciencemag.org/content/339/6119/548.full?sid=69b84ea1-59af-41bb-bd62-2ba7388ce195
The past few weeks have seen unprecedented action in terms of both fiscal policy initiatives and...
The past few weeks have seen unprecedented action in terms of both fiscal policy initiatives and monetary policy initiatives. In terms of size, timing, and coordination this is the fastest and strongest both entities have acted to 'alter' the economy. Please take some time to read 3 or 4 articles if you are not familiar with these actions. Briefly summarize 5 fiscal policy initiatives put in place recently, and what the Fed did in terms of Monetary Policy. This week...
8. You started a new full-time job a few weeks ago and you just learned that...
8. You started a new full-time job a few weeks ago and you just learned that your family owns part of a business that provides services to your employer. What should you do? Quit your job immediately. Disclose the conflict of interest to your manager. Report the situation to a third-party committee. 9. Which of the following signs indicate weak ethical culture in an organization? Select ALL relevant signs. The company has a channel for employees to report misconduct anonymously....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT