-1

Develop a C++ program that uses a while statement to determine the gross pay for each of
several employees. The company pays 10 RM per hour for the first 40 hours worked by
each employee and pays 20 RM per hour for all hours worked in excess of 40 hours. Your
program should determine and display the employee’s gross pay when information on
number of hours worked is given.
[Hint: use while loop for repetition. Input value -1 for hours worked, to end the repetition].
Sample of output:
Enter hours worked (-1 to end): 39
Salary is RM 390
Enter hours worked (-1 to end): 40
Salary is RM 400.00
Enter hours worked (-1 to end): 41
Salary is RM 415.00
Enter hours worked (-1 to end): -1
Pseudocode:
Prompt the user for the hours worked for an employee
Input the hours worked for the first employee
While the value (-1) has not been entered for the hours
If the hours input is less than or equal to 40
Calculate gross pay by multiplying hours worked by hourly rate
Else
Calculate gross pay by multiplying hours worked above forty by 2 times the hourly rate
and adding 40 hours worked by the hourly rate
Display the employee’s gross pay.
Input the hours worked for the next employee

2
Contributors
1
Reply
11
Views
4 Years
Discussion Span
Last Post by tinstaafl
0

An interesting homework assignment. Have fun.

Votes + Comments
Please report homework violations instead of posting something snarky. We *can* delete these, but not if there are any replies.
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.