Question
Assignment #8: Use ArrayLists In this assignment we will store all the data weve been entering in an array. Due to Javas inability to dynamically
Assignment #8: Use ArrayLists In this assignment we will store all the data weve been entering in an array. Due to Javas inability to dynamically resize arrays, we will use arraylists. Note that for this to work correctly we will need TWO array lists. 1. An array list of employees 2. An array list of PayPeriods INSIDE each employee. Be SURE to new your inner array in your employee constructor and create appropriate getter and setter methods on the OUTER class Input Expected: Same as Assignment #6 Sample Run: Inputs: Enter Employee Id: 123456 Enter Employee first name: Larry Enter Employee last name: Schoeneman Enter # of hours worked this week: 50 Enter hourly rate of pay: $10.00 Would you like to enter another employee? (Y/N) Output: (Complete list of employees) Employee Id : 123456 Last Name: Schoeneman First Name: Larry Week of 6/11/2020 (use current date) Hours Worked: 50 Hourly Rate: $10.00 Regular Pay: 40 hours at $10/hr: $400.00 Overtime Pay: 10 hours at $15/hr: 150 Gross Total: $650.00 After all employees are entered, display an employee list: Employee List Id Name ----------------------------------- 1 Larry Schoeneman 2 Bob Smith Use tabs and printf to format your list nicely (\t). Use an advanced for loop to print it. Specification: As before, read in the information as shown, and use the classes we built to print out the appropriate stubs. Now, after that is complete, ask the user if they would like to enter another employee. If yes, repeat the experience, otherwise, say goodbye and exit the program. We must also now GENERATE unique employee ids. I would suggest creating a function to generate these ids in the Payroll Manager class. Similary, Use a static integer for the payperiod id. I would also suggest that the Payroll manager would be a good place to store the employees themselves. Add a method to payroll manager to print an employee list. In this assignment we will properly format all our output. So, wherever we output $0.0 or $0.000000001 it should now output dollar amounts as: $xxxx.xx where the left side is as long as it needs to be, and the right side is always two digits. $123.45, $1.24, $123456.78 are valid examples. Hint: printf
Write a Java code for this assignment.
Assignment #4: Refactor to classes In this assignment we are going to refine the code we wrote above to make use of classes. The inputs and outputs should be the same as Assignment #3 with the following changes: 1. Add middle initial, address, email and phone information to input 2. No longer grab employee id, we want it generated and displayed Specification: In the prior assignment, you just wrote your code in a linear fashion to read from the keyboard, calculate it and output the results. We will now reorganize this into classes We are going to implement the following classes: 1. Employee - This class represents an employee. It should have the following fields implemented as getters and setters: a. Employee ID (we will need to make this unique, for now, just hard code it to 1). b. First name, Last name, Middle initial c. Address, City, Zip d. Phone, Email e. Hourly Rate 2. PayPeriod - This class represents an employee's payment information. An employee will eventually have more than one pay period. It should contain the following fields (implemented as getters and setters): a. Pay period id (hard code it for now) b. Employee Id (who is this for) C. Start Date, End Date d. Number of hours 3. PayrollManager - This class provides the functionality we need to compute and display our payroll. It should implement the following methods: a. double CalculateGrossPay (Employee, Payperiod) This should return the total gross for the payperiod b. double CalculateRegular Pay(Employee, Payperiod) - This should return the gross paid at the regular rate for the pay period double CalculateOvertimePay(Employee, Payperiod) This should return ONLY the gross overtime for the pay period d. void PrintPaystub(Employee, Payperiod) This should print out the paystub for the employee for the period. Note that here, we should use the other methods we defined above to implement this method. 4. Your main program will then do the following: Gather input and put in in an instance of Employee b. Gather payroll info and put it into an instance of Payperiod (default the dates for now) c. Call Print Paystub to display it. c. a. Expectations: You must create classes, with constructors, getters and setters as needed. You should comment your code intelligently You should separate your code logically into chunks (inputs, computation, printing, etc) You are expected to use if statements and class methods Assignment #5: Calculate Taxes In this assignment we are going to add logic to calculate taxes Input Expected: Same as Assignment #2 Sample Run: Inputs: Enter Employee Id: 123456 Enter Employee first name: Larry Enter Employee last name: Schoeneman Enter # of hours worked this week: 50 Enter hourly rate of pay: $10.00 Output: Employee Id : 123456 Last Name: Schoeneman First Name: Larry Week of 6/11/2020 (use current date) Hours Worked: 50 Hourly Rate: $10.00 Regular Pay: 40 hours at $10/hr: $400.00 Overtime Pay: 10 hours at $15/hr: 150 Gross Total: $650.00 Federal Tax: $65.00 State Tax: $35.00 FICA: $20.00 Net Pay: $530.00 Specification: We are going to add the following to our class set. a. 1. Create a new class called TaxPayment which has the following fields: FederalTax b. State Tax c. Fica Tax 2. Add an instance of this class to the pay period class 50 have a place to store it 3. Create a new class called TaxManager that has the following methods: a. TaxPayment ComputeTaxPayment(double grossPay, TaxRates taxRates) - This should return the taxes for this employee, which can then be stored in the payperiod class b. We are making TaxManager a separate class so eventually we have a place to put different tax rates 4. Use the following default rates for tax rates a. Federal Rate -15% b. State Rate -5% c. FicaRate-3 5. You should use Tax Manager in your printPaystub method to calculate and display the appropriate taxes. Example Input Enter Employee first name:Larry Enter Employee last name:Schoeneman Enter middle initial:X Enter address:1219 Rose Court East Enter city:Buffalo Grove Enter state:IL Enter zipcode:60089 Enter email:lschoeneman@harper.edu Enter phone:121-124-1234 Enter hourly rate of pay:10 Enter hours worked:40 Example Output Employee Id : 1 Last Name: Schoeneman First Name: Larry Middle Initial: X Address: 1219 Rose Court East, Buffalo Grove, IL 60089 Phone: 121-124-1234 Email:Ischoeneman@harper.edu Hours Worked: 40.0 Hourly Rate: $10.0 Gross Total: $400.0 Taxes: Federal Tax:$60.0 State Tax:$20.0 Fica Tax:$12.0 Net Paycheck: $308.0 Assignment #6: Enter Multiple Employees In this assignment we will take the classes we build in assignment 4 and 5, and use them to allow entry and printing of multiple employees Important: If you do a scanner.readint, it DOES NOT consume the return. The following sequence: System.out.print("Enter hourly rate of pay:"); double hourlykale scanner.nex Double(); System.out.print("Enter some other string:"); String otherString scanner.nextLine(); Will NOT work like you expect. If you enter "10" for rate of pay and hit return, it will use the return as input to "otherString" and won't ask for il. Whal. you need l.o do is gel. rid of the relurn as follows: System.out.print("Enter hourly rate of pay:"); double hourlyRate = scanner.next.Double(); System.out.print("Enter some other string:"); Scanner.nextLine(); // Cel rid of the extra relurn String otherstring= scanner.nextLine(); Input Expected: Same as Assignment #5 Sample Run: Inputs: Enter Employee first name:Larry Enter Employee last name:Schoeneman Enter middle initial:X Enter address:1219 Rose Court East Enter city:Buffalo Grove Enter state:IL Enter zipcode:60089 Enter email:Ischoeneman@harper.edu Enter phone:121-124-1234 Enter hourly rate of pay:10 Enter hours worked:40 Output: Employee Id : 1 Last Name: Schoeneman First Name: Larry Middle Initial: X Address: 1219 Rose Court East, Buffalo Grove, IL 60089 Phone: 121-124-1234 Email:Ischoeneman@harper.edu Hours Worked: 40.0 Hourly Rate: $10.0 Gross Total: $400.0 Taxes: Federal Tax:$60.0 State Tax:$20.0 Fica Tax:$12.0 Net Paycheck: $308.0 Would you like to enter another employee? (Y/N) Specification: As before, read in the information as shown, and use the classes we built to print out the appropriate stubs. Now, after that is complete, ask the user if they would like to enter another employee. If yes, repeat the experience, otherwise end the program Assignment #7: Format output In this assignment we will properly format all our output. So, wherever we output $0.0 or $0.000000001 it should now output dollar amounts as: $xXxx.xx where the left side is as long as it needs to be, and the right side is always two digits. $123.45, $1.24, $123456.78 are valid examples. Irint: printi Assignment #8: Use ArrayLists In this assignment we will store all the data we've been entering in an array. Due to Java's inability to dynamically resize arrays, we will use arraylists. Note that for this to work correctly we will need TWO array lists. 1. An array list of employees 2. An array list of PayPeriods INSIDE each employee. Be SURE to "new" your inner array in your employee constructor and create appropriate getter and setter methods on the OUTER class Input Expected: Same as Assignment #6 Sample Run: Inputs: Enter Employee Id: 123456 Enter Employee first name: Larry Enter Employee last name: Schoeneman Enter # of hours worked this week: 50 Enter hourly rate of pay: $10.00 Would you like to enter another employee? (Y/N) Output: (Complete list of employees) Employee Id : 123456 Last Name: Schoeneman First Name: Larry Week of 6/11/2020 (use current date) Hours Worked: 50 Hourly Rate: $10.00 Regular Pay: 40 hours at $10/hr: $400.00 Overtime Pay: 10 hours at $15/hr: 150 Gross Total: $650.00 After all employees are entered, display an employee list: Employee List Id Name 1 Larry Schoeneman 2 Bob Smith Use tabs and printf to format your list nicely (\t). Use an advanced for loop to print it. Specification: As before, read in the information as shown, and use the classes we built to print out the appropriate stubs. Now, after that is complete, ask the user if they would like to enter another employee. If yes, repeat the ence, otherwise, say goodbye and exit the program. We must also now GENERATE unique employee ids. I would suggest creating a function to generate these ids in the Payroll Manager class. Similary, Use a static integer for the payperiod id. I would also suggest that the Payroll manager would be a good place to store the employees themselves. Add a method to payroll manager to print an employee list. In this assignment we will properly format all our output. So, wherever we output $0.0 or $0.000000001 it should now output dollar amounts as: $xxxx.xx where the left side is as long as it needs to be, and the right side is always two digits. $123.45, $1.24, $123456.78 are valid examplesStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started