Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This code should include a while loop that allows the user to continue entering

ID: 3555312 • Letter: T

Question

This code should include a while loop that allows the user to continue entering employees as long as they want to continue:

int main()
{
Real payrate,hours, gross,again;

cout << "Enter the employees hourly pay rate. ";
cin >> payrate;

cout<< "Enter the total hours worked by employee. ";
cin >> hours;

while (payrate > 18.25 || payrate < 7.50)
{
    cout << "The valid value for pay rate is in the range. ";
    cout << " of $7.50 through $ 18.25. ";
    cout << "Enter a valid value for pay rate. ";
    cin >> payrate;
}

while (hours > 40 || hours < 0)
{
    cout << "Please enter hours worked between 0 and 40. ";
    cin >> hours;
}


gross = payrate * hours;
cout << "The gross pay of the employee is $ " << gross << endl;
}

It is probably simple but I still need help.

Explanation / Answer

int main()
{
Real payrate,hours, gross,again;
int flag=1;
while(flag==1)
{


cout << "Enter the employees hourly pay rate. ";
cin >> payrate;

cout<< "Enter the total hours worked by employee. ";
cin >> hours;

while (payrate > 18.25 || payrate < 7.50)
{
    cout << "The valid value for pay rate is in the range. ";
    cout << " of $7.50 through $ 18.25. ";
    cout << "Enter a valid value for pay rate. ";
    cin >> payrate;
}

while (hours > 40 || hours < 0)
{
    cout << "Please enter hours worked between 0 and 40. ";
    cin >> hours;
}


gross = payrate * hours;
cout << "The gross pay of the employee is $ " << gross << endl;

cout<<"you want to continue for another employee? . enter 0 if you dont,enter 1 if you want to ";
cin>>flag;

}

}

-----------------------------------------------------------------------------

additions have been shown in bold letter..