//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);
{
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.