Hi I'm new to c++ and I'm trying to write a program for class that is to figure out the different salaries between employees and I'm getting an error for illegal else without matching if in line 32 but I can't figure out whats wrong or where the missing brace is.
here is the code:
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <string>
using namespace std;
int main () {
string name;
char EmployeeType;
double HourlyRate;
double Hours;
double sum;
double gross;
double overtime;
double BaseSal;
double TotalGross;
int piece;
int sale;
double commission;
int returns;
double PiecePay;
double BaseGross;
;cout << "Enter the employee name: ";
getline (cin, name);
;cout << "Enter the salary type. "
;cout << "\n\tH\tHourly. ";
;cout << "\n\tP\tHourly plus piece credit. ";
;cout << "\n\tS\tHourly plus sales commission. ";
;cout << "\nEnter response here -----> ";
cin >> EmployeeType;
if(toupper(EmployeeType) == 'H' || toupper (EmployeeType) == 'P' || toupper (EmployeeType) == 'S')
{
else
{
if(toupper(EmployeeType) != 'H' || toupper (EmployeeType) != 'P' || toupper (EmployeeType) != 'S')
cout << "*****INVALID ENTRY***** ";
}
if(toupper(EmployeeType) == 'H' || toupper (EmployeeType) == 'P' || toupper (EmployeeType) == 'S')
{
//whatever you wanted to have happen
}//end if
elseif (toupper(EmployeeType) != 'H' || toupper (EmployeeType) != 'P' || toupper (EmployeeType) != 'S') //make this an else if statement
{
cout << "*****INVALID ENTRY***** ";
}
This should fix your issues. Also, you are missing a bracket in your code, thus giving you the error, re read over it, you can see some issues. Also, NEVER use the system("PAUSE");, it is a horrible habit, and you should never use it for programming projects that you plan on turning in for school or work. I think we have a sticky on it.