' Overtime Pay Program ' Employees over 40 hours make time and a half. ' PRINT "What is the base pay rate" INPUT RATE PRINT "How many hours" INPUT HOURS IF HOURS > 40 THEN LET OVERTIME = HOURS - 40 ELSE LET PAY = HOURS * RATE END IF
Let us check that the program is correct so far. Say that Ann has a base rate of $10 per hour and has worked 50 hours. The program starts out:
What is the base pay rate ? 10 How many hours ? 50
The first INPUT
statement puts 10 in RATE
.
The second INPUT
statement puts 50 in HOURS
.
Now the IF
statement looks like:
IF HOURS > 40 THEN ^ | +--- contains a 50
Because 50 > 40 is true, the true branch is executed.
This puts 10 hours in OVERTIME
:
LET OVERTIME = HOURS - 40 ^ | +--- contains a 50
For this example the program works correctly. Now you need to finish the program. PAY for employees with overtime will be 40 hours times the base rate, plus 1.5 times the OVERTIME hours times the base pay rate.
' Overtime Pay Program ' Employees over 40 hours make time and a half. ' PRINT "What is the base pay rate" INPUT RATE PRINT "How many hours" INPUT HOURS IF HOURS > 40 THEN LET OVERTIME = HOURS - 40 LET PAY = _______________________________ ELSE LET PAY = HOURS * RATE END IF ' PRINT "Your pay is", PAY END
Fill in the final blank to complete the program.