Mar 25, 2009 at 7:42am UTC
this is the source code of a program i want to run.
however it could not compile.
can you edit it for the errors inside?
#include <iostream.h>
#include <stdlib.h>
int main()
{ char M,F,category;
int hrs_worked,OT_hrs;
double Net_Wage,hourly_rate,M_Gross_pay,F_Gross_pay,Tax_Deduction,Gross_pay,tax_rate;
const double OT_rate = 1.5;
const int Nor_working_hrs = 40;
const double Mhrly_rate = 10.60;
const double Fhrly_rate = 8.30;
const double MTax_rate = 0.35;
const double FTax_rate = 0.20;
cout << "\t*************************************" <<endl<<endl;
cout << "\tWage Calculator for Shoe Lace Company" <<endl<<endl;
cout << "\t*************************************" <<endl<<endl;
cout << "Enter Category: 'M' for Management, 'F' for Floor Workers: " <<endl<<endl;
cin >> category;
cout << "Enter Hours Worked: " <<endl<<endl;
cin >> hrs_worked;
cout << "\tSummary:" << endl;
cout << "\t-------" << endl;
// calculations
M_Gross_pay = Nor_working_hrs*Mhrly_rate + (OT_rate*Mhrly_rate*OT_hrs); //computing managers' gross pay
F_Gross_pay = Nor_working_hrs*Fhrly_rate + (OT_rate*Fhrly_rate*OT_hrs);//computing floor workers' gross pay
OT_hrs = hrs_worked - Nor_working_hrs; //computing overtime hours
if (category == 'M');
{
hourly_rate = Mhrly_rate;
Gross_pay = M_Gross_pay;
tax_rate = MTax_rate;
Tax_Deduction = MTax_rate*Gross_pay;
Net_Wage = Gross_pay - Tax_Deduction;
}
else
{
hourly_rate = Fhrly_rate ;
Gross_pay = F_Gross_pay;
tax_rate = FTax_rate;
Tax_Deduction = FTax_rate*Gross_pay;
Net_Wage = Gross_pay - Tax_Deduction;
} */
cout << "\tStaff Category: " << category << endl;
cout << "\tHourly Rate: " << hourly_rate << endl;
cout << "\tTax Rate: " << tax_rate << endl << endl;
cout << "\tHours Worked: " << hrs_worked << endl;
cout << "\tOvertime Hours: " << OT_hrs << endl;
cout << "\tGROSS PAY:$ " << Gross_pay << endl << endl;
cout << "\tTax Deductions:$ " << Tax_Deduction <<endl;
cout << "\tNET WAGE:$ "<<endl<<endl;
system("PAUSE");
return 0;
}
Mar 25, 2009 at 8:54am UTC
Remove:
1. ;
after if (category == 'M' )
2. */
after else body
3. {
before char M,F,category;
Mar 25, 2009 at 12:06pm UTC
Your compiler will tell you where (approximately) the error occurs in your code. When an error is reported, it gives you a line number. Check out that line number, as well as the line above it, and see if you can spot an error. Even if you don't understand exactly what the error message means, you might be able to spot a mistake simply by checking the right location in your code.