P04 Pseudocode and Report Layout |
|
Pseudocode similar to this was developed in class for P04.
Report Layout:
Not all required variables are represented in layout.
Week Rate Hours 1.0 1.5 2.0 Total
W1 rate w1Hours w1Pay1 w1Pay2 w1Pay3 w1Total
W2 rate w2Hours w2Pay1 w2Pay2 w2Pay3 w2Total
W3 rate w3Hours w3Pay1 w3Pay2 w3Pay3 w3Total
W4 rate w4Hours w4Pay1 w4Pay2 w4Pay3 w4Total
Employee totals: empHours empPay1 empPay2 empPay3 empTotal
Report totals:
reportHours reportPay1 reportPay2 reportPay3 reportTotal
empCount and average
P04 Design:
void main()
{
declare constants
declare variables (see below)
initialize accumulators to zero
get empCount (do-while)
loopCount = 1;
while (loopCount <= empCount)
{
get rate (do-while)
get hours w1, w2, w3, w4 (do-while)
calculate pay for 4 weeks (see if-else statements below)
sum week totals (cross foot)
sum emp totals (columns)
accumulate report totals
display headings
display detail lines (4 weeks)
display employee totals
display continue prompt
loopCount++
}
calculate average
display report totals
display empCount and average
return
}// end of main
Calculate pay:
Week1
if (w1Hours < 41)
{
w1Pay1 = w1Hours * rate;
w1Pay2 = 0;
w1Pay3 = 0;
}
else
{
if (w1Hours < 51)
{
w1Pay1 = 40 * rate;
w1Pay2 = (w1Hours - 40) * rate * RATE2;
w1Pay3 = 0;
}
else
{
w1Pay1 = 40 * rate;
w1Pay2 = 10 * rate * RATE2;
w1Pay3 = (w1Hours - 50) * rate * RATE3;
}//else
}//else
Week2
Week3
Week4