Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Here is the question: In this exercise, you will create a program that displays the gross pay for one or more Employees. Use a negative

Here is the question:

In this exercise, you will create a program that displays the gross pay for one or more Employees. Use a negative sentinel value to stop the program. Employees are paid at their regular pay rate for hours worked from 1 through 37. They are paid time and a half for the hours worked from 38 through 50, and double-time for the hours worked over 50. Use a void function to calculate and return the employees overtime pay, if applicable.

I am able to get the correct calculated output. The issue I am having is when entering -1 to stop the loop it continues. Please advise what I have done wrong. Thanks!

#include

#include

using namespace std;

double getGrossPay(int hours, double payRate);

int main()

{

int dummy;

int hours = 0;

double payRate = 0.0;

double grossPay = 0.0;

while (hours != -1)

{

cout << "Enter the number of hours the employee worked (: enter -1 to stop) ";

cin >> hours;

cout << "Enter employee's hourly pay rate: ";

cin >> payRate;

double grossPay = getGrossPay(hours, payRate);

cout << "Employee's Total Gross Pay: $" << grossPay << endl;

cout << endl;

} //end while

cout << "Enter next employee's number of hours worked: ";

cin >> hours;

cout << " Enter nexts employee's hourly pay rate: ";

cin >> payRate;

cin >> dummy;

return 0;

} // end main function

double getGrossPay(int hours, double payRate)

{

double grossPay = 0.0;

if (hours >= 1 && hours <= 37)

{

grossPay = hours * payRate;

}

else

if (hours >= 38 && hours <= 50)

{

grossPay = (hours - 37) * (payRate * 1.5) + (37 * payRate);

}

else

if (hours >= 51)

{

grossPay = (hours - 50) * (payRate * 2) + (37 * payRate) + (13 * (payRate * 1.5));

}

return grossPay;

// end if

// end if

//end if

} //

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Describe the factors influencing of performance appraisal.

Answered: 1 week ago

Question

What is quality of work life ?

Answered: 1 week ago

Question

d. What language(s) did they speak?

Answered: 1 week ago