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

An interesting homework assignment. Have fun.

commented: Please report homework violations instead of posting something snarky. We *can* delete these, but not if there are any replies. -3
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.