Sale!

CSC/BIF 245 Assignment 1 Classes and Objects solution

$30.00 $21.00

Original Work ?

Download Details:

  • Name: Assignment1-mceha3.zip
  • Type: zip
  • Size: 29.97 KB

Category: You will Instantly receive a download link upon Payment||Click Original Work Button for Custom work

Description

5/5 - (1 vote)

You are  asked to write a program to manage the employees of a company.  The program should contain two classes Employee and Company. The main method should be written in class  Company. Class Company has an array of employees. Each employee has a name (of type String), a hire day (of type String) and a salary (of type double).

 

The program starts by displaying the following menu on the screen:

 

  • Add employee
  • Delete employee
  • Raise salary
  • List all
  • Exit

———————-

Enter your choice:

 

The Add option –  If the user inputs 1, the program prompts for the name, salary , and hire day of the employee. An object  is then created and added to the array. Two employees are considered equal if they have the same name and the same hire day. The company cannot have two employees that are equal.

 

The Delete option- If the user enters 2, the program prompts for the name and hire day of the employee, searches for it and if it finds it, deletes the employee from the  array  and then outputs a message saying that the record for the employee has been deleted. If the employee   is not found, an appropriate message is displayed.

 

The Raise Salary option – If the user chooses option 3, he/she is prompted for the name of the employee. All employees with the input name are displayed in a numbered list as such:

  1. John Doe, 03/01/2020
  2. John Doe, 01/01/1800
  3. John Doe,  02/10/ 1998

The user is then prompted for the number of the employee, i. When this information is input, the user is prompted for the percentage of the increase to apply to the salary of the ith employee in the list and the salary is updated accordingly. For example, if the user inputs 1 for i and then 3 for the raise, the salary of the first John Doe on the list is increased by 3%.

 

 

The List  All option – If the user enters 4, the information of all the employees is displayed, one employee per line.

 

The Exit option- If the user enters 5, the program terminates.

 

The menu is displayed again after each option except the Exit option which terminates the program.

 

Any choice from the menu other than 1,2, 3, 4 or 5  displays a message informing the user of the invalidity of the choice and prompts for it again.

 

There are two ways to end the program normally: either by having the user choose the Exit option or when an invalid choice is entered more than 5 consecutive times.

 

Notes:

 

  • Override the method toString() in the appropriate classes. Use it!
  • If you need to compare two employees for equality, make sure you implement the method equals(). So, now if you have two instances employee1 and employee2 and they have the same name and the same hire day, the following statement will return true:

 

employee1.equals(employee2);

 

  • You may assume that the user will always enter the correct type of data (i.e. numbers for salaries, strings for names, etc.).
  • Following the good coding practice guidelines we have seen in class.
  • Use casting only where necessary.