file
ICSI 213 Assignment 2 – Finish the payroll system You must submit .java files. Any other file type will be ignored. Especially “.class” files. You must not zip or otherwise compress your assignment. Blackboard will allow you to submit multiple files. You must submit buildable .java files for credit. Introduction In this assignment, we are going to finish working on a payroll system. We will create arrays of employees, sort them, search them, and create some reports to complete payroll. This will ensure that you have a solid understanding of searching, sorting and polymorphism. You may not use Java’s built-in searches or sorts in this assignment; doing so will disqualify your assignment. Details Build a class: Payroll. Payroll should contain an array of employees. 100 should be enough. It will contain a main method that displays a menu of options and allows the user to choose one of the following options: 1) Create an employee 2) Search for an employee by last name 3) Display an employee by employee number 4) Run payroll 5) Quit When a user makes a selection, a different method is called (see below) except for quit (quit exits the program). Any other input should inform the user that their choice is not valid. The program should then loop to print the menu again. Create an employee Create a well named method in Payroll to implement this functionality. Ask the user for a first name and a last name. Ensure that they enter something and that it contains only letters, spaces, and hyphens. If not, ask the user to re-enter. If the first name or last name is “q”, return to the main menu. Ask the user for employee type (Salaried, Commissioned, Hourly). If the employee is hourly, ask their pay rate. If the employee is salaried, ask their yearly salary. If the employee is commissioned, ask their yearly base pay and then allow the user to enter a commission schedule: Ask number of units. If number of units is “q”, the commission schedule is complete. Then ask value per unit. Repeat until the user quits. Create an employee of the appropriate type, add it to the array of employees and return to the main menu. Note – you will have to keep track of the next index OR determine the next index before adding. Search for an employee by last name Create a well named method in Payroll to implement this functionality. Ask the user for the last name. Ensure that they enter something and that it contains only letters, spaces, and hyphens. If not, ask the user to re-enter. If the first name or last name is “q”, return to the main menu. Use quicksort to sort the employees by last name, then by first name. Then use sequential search to find the employees (there may be more than one!) with the same last name. You can quit the search once you pass the last name. Print them in this format: John Smith Employee 1234 Roland Smith Employee 2345 Display an employee by employee number Create a well named method in Payroll to implement this functionality. Ask the user for the employee number. If the user enters “q”, return to the main menu. Ensure that the user entered a valid number – greater than or equal to 0 and within the range of the employee numbers that have been assigned. Use quicksort to sort the employees by employee number. Use binary search to find the specified employee. Print it using the “ToString” format that we built in assignment 1. Run Payroll Create a well named method in Payroll to implement this functionality. For each hourly employee, ask how many hours they worked. Use the mutator to store this. For each commissioned employee, ask how many units that they sold. Use the mutator to store this. There are no questions for salaried employees. If the user enters “q” for any of these questions, ask them to confirm that they want to quit and that they will lose any values that they have entered so far. Use selection sort to sort the employees by highest paycheck first. As soon as you find the highest paycheck, print it in the following format: Phipps, Michael$32,178.22 Jones, Thomas $234.18 The amounts should be right aligned – all of the cents should line up down the page When the printing is complete, print “End of Payroll” on its own line and return to the main menu. HINTS There are some requirements in this assignment that are repeated. You should make helper methods that implement that functionality. There are sub-tasks in this assignment that you should notice and put in their own methods. More methods are usually better than less. Rubric Poor OK Good Great Comments None/Excessive (0) “What” not “Why”, few (4) Some “what” comments or missing some (7) Anything not obvious has reasoning (10) Variable/Function naming Single letters everywhere (0) Lots of abbreviations (4) Full words most of the time (8) Full words, descriptive (10) Payroll – class None (0) Class is public, in a filename that matches the class name and has appropriate inheritance (2) Payroll – main – menu None (0) Three of: Menu is printed, in an appropriate loop, quits correctly, calls the correct function, rejects invalid entries correctly (2) Menu is printed, in an appropriate loop, quits correctly, calls the correct function, rejects invalid entries correctly (4) Payroll – employee array None (0) Has an array of 100 employees (2) Create An Employee – user interface None (0) Understandable instructions, detects invalid inputs, quits on demand (8) Create an Employee – creates and adds None (0) Creates the appropriate type of employee OR adds something to the array (2) Creates the appropriate type of employee and adds them to the array (5) Name Search – user interface None (0) Understandable instructions, detects invalid inputs, quits on demand (5) Name Search – quick sort None or not quick sort (0) Sorts only by last name (3) Sorts correctly by last name, then first name (7) Name Search – sequential search None (0) Searches but doesn’t quit until the end (4) Searches and quits as soon as possible (6) Name Search – printing None (0) Prints correctly (3) Emp # Search – user interface None (0) Understandable instructions, detects invalid inputs, quits on demand (5) Emp # Search – quicksort None or not quick sort (0) Quicksorts correctly (6) Emp # Search – binary search None or not binary search (0) Binary searches correctly (6) Emp # Search – printing None (0) Prints correctly (3) Payroll – user interface None (0) Understandable instructions, detects invalid inputs, quits on demand, stores information correctly (5) Payroll – sorting None or not selection sort (0) Uses selection sort and outputs records as soon as possible (7) Payroll – printing None (0) Wrong format (3) Correctly formatted, prints end message (5) Helper methods None (0) Several that help clarity and conciseness (5)