Expected Expression Help

closed account (1RiLb7Xj)
//HI, I am doing a program on Calculating Pay of Workers based on Several //Variables. However, I am getting an error on the last else line at the bottom //of my code. I'm not sure why it's prompting Expected Expression as an error. //Any Help is appreciated.

#include <iostream>
#include <string>
#include <iomanip>
using namespace std;

int main ()
{
cout << fixed << showpoint << setprecision (5);
char BasePayCode;
int JobClassCode;
int YearsOfService;
int EduLvl;
int IDNum;

cout << "Please Enter your first and last name only: ";
string FirstLast;
cin >> FirstLast;
cout << "Hello " << FirstLast << endl;
cout << "Welcome to The BadWater Brewery Pay Calculator. We will calculate your pay. " << endl;
cout << "Please enter your employee code (S , O, or M ): ";
cin >> BasePayCode;
bool flagBasePayCode = (BasePayCode == 'S') || (BasePayCode == 'O') || (BasePayCode == 'M');
cout << "Please enter your employee ID Number: " <<endl;
cin >> IDNum;
cout << "We would like you to enter you Job Classification Code: "<<endl;
cout << "Enter (1, 2 or 3): ";
cin >> JobClassCode;
bool flagJobClassCode = (JobClassCode == 1) || (JobClassCode == 2) || (JobClassCode == 3);
cout << "Now we would like to know your Years of Service to the company: "<<endl;
cout << "Please enter a number less than 50, as the bonus pay caps at 50."<<endl;
cin >> YearsOfService;
bool flagYearsOfService = (0<= YearsOfService || YearsOfService <= 50);
cout << "Now we will like you to Enter your Education Level Code: " <<endl;
cout << "Please enter (1 for Highschool, 2 for Junior College, 3 for University, or 4 for Graduate SChool): " << endl;
cin >> EduLvl;
bool flagEduLvl = (EduLvl == 1) || (EduLvl == 2) || (EduLvl == 3) || (EduLvl == 4);

if (flagBasePayCode && flagJobClassCode && flagYearsOfService && flagEduLvl);
{
double BasePay = 0.0;
if (BasePayCode == 'S')
{
BasePay = 800.95;
}
else if (BasePayCode == 'O')
{
BasePay = 1000.86;
}
else if (BasePayCode == 'M')
{
BasePay = 1499.89;
}
double incrJobClass = 0.0;
if (JobClassCode == 1)
{
incrJobClass = BasePay * .05;
}
else if (JobClassCode == 2)
{
incrJobClass = BasePay * .10;
}
else if (JobClassCode == 3)
{
incrJobClass = BasePay * .20;
}
int incrYearsOfService = 0;
if (YearsOfService == (0<= YearsOfService || YearsOfService <=10))
{
incrYearsOfService = BasePay * .05;
}
else if (YearsOfService == (11 <= YearsOfService || YearsOfService <= 50))
{
incrYearsOfService = (BasePay * .05) + ((YearsOfService -10) * .01 * BasePay);
}
int incrEduLvl = 0;
if (EduLvl == 1)
{
incrEduLvl = 0.0;
}
else if (EduLvl == 2)
{
incrEduLvl = BasePay * .05;
}
else if (EduLvl == 3)
{
incrEduLvl = BasePay * .12;
}
else if (EduLvl == 4)
{
incrEduLvl = BasePay * .20;
}
double RawTotalPay = (BasePay + incrJobClass + incrYearsOfService + incrEduLvl);
double TotalPennies = RawTotalPay * 100;
int RoundedPennies = static_cast<int>(TotalPennies + 0.5);
int Dollars = RoundedPennies / 100;
int Cents = RoundedPennies % 100;

else
{
cout << "One or more codes or entries prevent us from calculating your total pay." << endl;
}


return 0;
}

// The Last else line is prompting Expected Expression. Any help is //appreciated. Thanks!

1
2
if (flagBasePayCode && flagJobClassCode && flagYearsOfService && flagEduLvl);
{
That semi-colon there makes your if-statement have nothing in its body.
Remove semi-colon.

Edit your post and add code formatting.

[code]

 {program text here}

[/code]


if (YearsOfService == (0<= YearsOfService || YearsOfService <=10))
This if condition makes no sense. (I mean, technically it makes sense, but almost certainly not in the way you intend.)

If you're getting a compile-time error, post the exact, full error message.
An else statement has to immediately follow an if statement. You can't have random stuff in between; it's a branch.
Last edited on
Topic archived. No new replies allowed.