English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

this structured pseudocode should described how my paycheck is calculated. is got to have at least two decisions.

input hourlyPayRate
input hoursWorked
input percentageGrossSalaryWithheld
if an employee an has worked over 40 hours then
pay him time and have for hours worked over 40
else
paying him regular time
endif
if a raise has been giving then
increased withholdingAmount
else
let grossPay = hourlyPay * hoursWorked
let withholdingAmount = grossPay * percentageGrossSalaryWithheld
let netPay = withholdingAmount - grossPay
endif
stop

2007-09-07 06:31:19 · 3 answers · asked by caleb 1 in Computers & Internet Programming & Design

3 answers

Instead of using:
if an employee an has worked over 40 hours then
pay him time and have for hours worked over 40
else
paying him regular time
endif

Use this:
comment Declare a variable for over time rate and assign it comment a value

commant Declar a variable for time and a half and assign it a comment value


OverTime = hourlyPayRate * 1.5
If hoursWorked > 40 then
Time_and_a_Half = TotalhoursWorked - 40
TotPay = (Time_and_a_Half * OverTime) + (40 * hourlyPayRate)
else
TotPay = 40 * hourlyPayRate

The rest of the pseudo code is acceptable.

2007-09-07 07:26:35 · answer #1 · answered by ShyShy 2 · 0 0

General comments:

Use indentation to make clear which logic is part of the IF and ELSE statements

Develop some lines a little more. Don't say "Pay him regular time", give a little detail about how to compute regular pay. Ditto for the overtime block.

The raise logic should appear before you compute regular or overtime pay, since (assuming the raise has taken effect) it will affect how much pay you get.

Finally, the last few lines (except the STOP stmt) are computing gross and net pay, which you imply you're doing inside the first IF statement. Do you intend to compute it twice?

Oh - and it's "time and a half", not "time and a have". Compilers can't guess at poor spelling.

2007-09-07 13:47:15 · answer #2 · answered by Ralfcoder 7 · 0 0

If a raise has NOT been given then grossPay, withholdingAmount and netPay are not calculated. You need to move those outside the else condition (put them after the last endif and before stop).

2007-09-07 13:44:37 · answer #3 · answered by nonlinear 6 · 0 0

fedest.com, questions and answers