Needs to be in basic pseudocode. 2) A company maintains its employee records in
ID: 3869038 • Letter: N
Question
Needs to be in basic pseudocode.
2) A company maintains its employee records in a sequential text file named employees.txt. The record for each employee contains the following: ID number, employee’s name, hourly pay, hours worked, benefits contribution, retirement account contribution.
Assume that the following declarations have already been made
num id
string employeeName
num hourlyPay
num hoursWorked
num benefitsContribution
num retirementContribution
num grossPay
num incomeTax
num netPay
Declare any other variables and constants that are needed and write pseudocode so that your program can
a) Read each record in the employees.txt file
b) Calculate the employee’s gross pay, based on their hourly pay and how many hours they worked
c) Calculate the employee’s net pay after deducting the following:
i) the benefits contribution
ii) the retirement account contribution
iii) income tax, based on the following scale:
(1) gross pay of 1,000 or more: 10%
(2) gross pay of 750 or more but less than 1000: 7.5%
(3) gross pay of 500 or more but less than 750: 5%
d) Write the employee data along with the gross pay, benefits and retirement account contributions, income tax (in dollars), and net pay to another file named payroll.txt
Explanation / Answer
Main method:
open "employees.txt" for reading as fin;
open "payroll.txt" for writing as fout;
while(fin does not reach end of file)
{
input id from fin;
input employeeName from fin;
input hourlyPay from fin;
input hoursWorked from fin;
input benefitsContribution from fin;
input retirementContribution from fin;
grossPay=hourlyPay*hoursWorked;
if(grossPay>=1000)
incomeTax=grossPay*.1;
else if(grossPay>=750 and gross pay<1000)
incomeTax=grossPay*.075;
else
incomeTax=grossPay*.05;
end
netPay=grossPay-benefitsContribution-retirementContribution-incomeTax;
write fout,id,e,mployeeName,hourlyPay,hoursWorked,benefitsContribution,retirementContribution,grossPay,incomeTax,netPay,endline;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.