You are on page 1of 2

Pascal Exercise

1. Complete the program below. The purpose of the program is to calculate gross pay
(total pay before tax) based on the following:
• The standard number of hours is 40
• The program should read in the rate of pay
• The program should read in the number of hours worked
• The program should calculate:
The amount of pay for base hours
The number of hours worked overtime
The amount for overtime at 1.5 times the base rate
The total (gross) pay
• The program should display the gross pay

2. Type the program into the Pascal editor.

3. Compile the program ( > Compile > Compile or ALT & C)

4. Run the program & check that it works correctly.


Program wages (input, output);

{Compute total pay (base pay plus overtime pay) }

const
base_hrs = 40; {hours for which employee is paid base pay}
ot_rate = 1.5; {overtime rate}

var
hours : real; {total hours worked (must be greater than or equal to 40) }
baserate : real; {hourly pay rate}
base_pay : real; {pay for first 40 hours}
overtime : real; {hours worked in excess of 40 hours}
ot_rph : real; {overtime rate per hour - 1.5 times the pay rate}
ot_pay : real; {pay for overtime hours}
gross_pay : real; {base play plus overtime pay – total pay}

Begin {program wages}


{Read input values – hours worked and pay rate.}
WRITE (‘Enter the number of hours worked: ‘);
READLN ___________________________________________________
WRITE____________________________________________________
READLN___________________________________________________

{Compute base pay.}

Base_pay :=_________________________________________________

{Compute overtime pay.}

Overtime :=_________________________________________________
OT_rph := _________________________________________________
OT_pay := _________________________________________________

{Compute gross pay.}

gross_pay := ________________________________________________

{Display gross pay.}

WRITELN (‘The gross pay is $’,__________________________________


end. {Program Wages}

You might also like