C++ cout not displayed after while loop

Am having a problem with the following program not displaying the cout after the while loop, it doesn't ask if I want to enter another employee but just prompts for the employee payrate again. Can someone help me please?


#include <iostream>
using namespace std;

int main()
// Parameters: None
// Returns: Zero
// Calls: None
{
const double SOCIAL_SECURITY_TAX_PERCENT = 0.06;
const double FEDERAL_INCOME_TAX_PERCENT = 0.14;
const double STATE_INCOME_TAX_PERCENT = 0.05;
const double UNION_DUES_CHARGE = 10.00;
const double INSURANCE_CHARGE = 35.00;

double PayRate;
double HoursWorked; // number of hours worked
int Dependents; // number of dependents

double regular_hours;
double overtime_hours;
double Gross_Pay;
double regular_pay;
double overtime_pay;
double Social_Security_Amount;
double Federal_Income_Tax_Amount;
double State_Income_Tax_Amount;
double Union_Dues_Amount;
double Insurance_Amount;
double Total_Deductions;
double Net_Pay;

char again; //Does user want to go thru loop?

cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);

cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);

cout << "Calculate the weekly Net pay" << endl;
cout << "owed to an employee at a given Pay Rate " << endl;
cout << "for the Given number of Hours Worked" << endl
<< "and the given number of Dependents claimed." << endl;

do // begin loop
{

cout << "\n\nEnter the employee's Pay Rate: ";
cin >> PayRate;
cout << "\nEnter the employees's Hours Worked: ";
cin >> HoursWorked;
cout << "\nEnter the emploee's Number of Dependents: ";
cin >> Dependents;
cout << endl;

if (HoursWorked > 40)

{
overtime_hours = HoursWorked - 40;
regular_pay = PayRate * 40;
overtime_pay = 1.5 * PayRate * overtime_hours;
}

else
{
regular_pay = PayRate * HoursWorked;
overtime_pay = 0;
}

}

while (Gross_Pay = regular_pay + overtime_pay);
{
Social_Security_Amount = Gross_Pay * SOCIAL_SECURITY_TAX_PERCENT;
Federal_Income_Tax_Amount = Gross_Pay * FEDERAL_INCOME_TAX_PERCENT;
State_Income_Tax_Amount = Gross_Pay * STATE_INCOME_TAX_PERCENT;
Union_Dues_Amount = UNION_DUES_CHARGE;


if (Dependents > 2)
{
Insurance_Amount = INSURANCE_CHARGE;
}

else
{
Insurance_Amount = 0;
}

Total_Deductions = Social_Security_Amount
+ Federal_Income_Tax_Amount
+ State_Income_Tax_Amount
+ Insurance_Amount
+ Union_Dues_Amount;

Net_Pay = Gross_Pay - Total_Deductions;
}
cout << " Pay Rate $" << PayRate << endl;
cout << " Hours Worked " << HoursWorked << endl;
cout << " Regular Pay $" << regular_pay << endl;
cout << " Overtime Pay $" << overtime_pay << endl;
cout << " Gross Pay: $" << Gross_Pay << endl;
cout << " Deductions: $" << endl;
cout << " Social Security: $" << Social_Security_Amount << endl;
cout << " Federal Income Tax: $" << Federal_Income_Tax_Amount << endl;
cout << " State Income Tax: $" << State_Income_Tax_Amount << endl;
cout << " Union Dues: $" << Union_Dues_Amount << endl;
cout << " Health Insurance: $" << Insurance_Amount << endl;
cout << " Total Deductions: $" << Total_Deductions << endl;
cout << " NetPay: $" << Net_Pay << endl;

cout << "\nDo you want to do another employee (Y/N)? ";
cin >> again;
while (again == 'y' || again == 'Y');

cout << "\nEnd of PayRoll program!\n";



return 0;
}


Remove the stray semi-colon at the end of the while statement.

Aceix.
Topic archived. No new replies allowed.