Nov 7, 2012 at 4:24pm UTC
Hi, this is a simple program to calculate a payroll, excuse my lack of comments.
It's giving me the error in the subject, and:
expected primary-expression before "else"
expected `;' before "else"
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
double hours = 0.0;
double hourrate = 0.0;
double grosswages = 0.0;
double taxwages = 0.0;
char tax;
cout << "Enter hours worked: " << endl;
cin >> hours;
cout << "Enter hourly rate: " << endl;
cin >> hourrate;
cout << "Exempt? (y/n): " << endl;
cin >> tax;
grosswages = (hours * hourrate);
taxwages = (grosswages * 0.84);
if (tax == 'y' )
{
cout << "Gross wages = " << grosswages << fixed << setprecision(2) << endl;
cout << "NO TAXES DEDUCTED" << endl;
}
else if
{
cout << "Gross wages = " << grosswages << fixed << setprecision (2) << endl;
cout << "Wages after taxes = " << taxwages << fixed << setprecision(2) << endl;
}
else
cout << "YORO" << endl;
system ("pause" );
return 0;
}
Thank you!~
Last edited on Nov 7, 2012 at 4:25pm UTC
Nov 7, 2012 at 4:27pm UTC
You forgot the if condition on line 32
Nov 7, 2012 at 4:28pm UTC
else if is missing a condition.
you forgot tax == 'n'