Debug03-02: // This pseudocode is intended to display employee net pay values. /
ID: 671952 • Letter: D
Question
Debug03-02:
// This pseudocode is intended to display employee net pay values.
// All employees have a standard $45 deduction from their checks.
// If an employee does not earn enough to cover the deduction,
// an error message is displayed.
start
Declarations
string name
num hours
num rate
num DEDUCTION = 45
string EOFNAME = "ZZZ"
num gross
num net
output "Enter first name or ", EOFNAME, " to quit"
input name
if name not equal to EOFNAME
output "Enter hours worked for ", name
input hours
output "Enter hourly rate for ", name
input rate
gross = hours * rate
net = gross - DEDUCTION
while net > 0 then
output "Net pay for ", name, " is ", net
else
output "Deductions not covered. Net is 0."
endwhile
output "Enter next name or ", EOFNAME, " to quit"
input name
endif
output "End of job"
stop
Explanation / Answer
start
Declarations
string name
num hours
num rate
num DEDUCTION = 45
string EOFNAME = "ZZZ"
num gross
num net
output "Enter first name or ", EOFNAME, " to quit"
input name
while name not equal to EOFNAME
output "Enter hours worked for ", name
input hours
output "Enter hourly rate for ", name
input rate
gross = hours * rate
net = gross - DEDUCTION
if net > 0 then
output "Net pay for ", name, " is ", net
else
output "Deductions not covered. Net is 0."
endif
output "Enter next name or ", EOFNAME, " to quit"
input name
endwhile
output "End of job"
stop
It should be while because you want to repeat the process untill name != 'ZZZ'. using 'if' will not loop the process.
if net>0 then is correct, earlier while is used, which will become a infinite loop, since there is no change in the terminating condition.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.