In: Computer Science
How do you validate in pseudocode a "REPEAT" "UNTIL" loop? For example if a user inputs invalid data there should be an error message that reprompts for correct data.
To show this can you write Pseudo Code for the following problem?
Create an application that can determine the yearly bonus for all company employees. Not all employees are eligible for a yearly bonus. Only employees that have been with the company longer than 2 years and must have been given a rating of “Great”. Employees receiving a rating of “Bad” are not eligible for a bonus. Lastly, each department awards a different bonus amount based on percentage of yearly salary as shown below.
IT = 5% bonus
Sales=8% bonus
The application should allow the user to continually input employee data until the HR representative has reviewed all employees and has indicated they are finished entering employee data. One by one, the application will enable the HR representative to input an employee’s name, years of service, department, rating and salary. Based on data provided, the application must print well-formatted detail stating whether or not the employee is eligible for a bonus. For employees eligible for a bonus, the application must also print the amount of the bonus to be awarded to the employee. Upon completion of entering all employee data, the application will print a report that includes the total number of employees entered by the HR representative, a count of employees that are eligible for a bonus, and the average bonus amount.
START
// Intializing Variables
TotalNoOfEmployees = 0
TotalBonus = 0
CountOfBonusEmployee = 0
AverageBonus = 0
//Loop for Entering the Data of Employees by HR
REPEAT
INPUT Name
INPUT YearsOfService
INPUT Department
INPUT Rating
INPUT Salary
TotalNoOfEmployees = TotalNoOfEmployees + 1 //Total Number of Employees entered by HR
IF YearsOfService > 2 AND Rating == Great
PRINT Employee is eligible for bonus
IF Department == IT
Bonus = Salary + 0.05 * Salary
TotalBonus = Bonus + TotalBonus
CountOfBonusEmployee = CountOfBonusEmployee + 1
ELSE IF Department == Sales
Bonus = Salary + 0.08 * Salary
TotalBonus = Bonus + TotalBonus
CountOfBonusEmployee = CountOfBonusEmployee + 1
ENDIF
ELSE
PRINT Employee is not Eligible for bonus
ENDIF
UNTIL (HR representative has reviewed all the Employee and Finished entering all Employee Details)
AverageBonus = TotalBonus / CountOfBonusEmployee
PRINT TotalNoOfEmployees
PRINT CountOfBonusEmployee
PRINT AverageBonus
STOP