your first do/while was wonky so I fixed it. The program isn't complete, but it compiles and takes your first number selection properly
Code
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main()
{
int EmployeeType{0};
double HourlyRate{0};
double AnnualSalary{0};
double HoursWorked{0};
double Pay{0};
do
{
cout << "Enter Employee type.\nHourly Employee: 1\nSalary Employee: 2\nExit program: -1\n";
cin >> EmployeeType;
if (EmployeeType != -1 && EmployeeType != 1 && EmployeeType != 2) {
cout << "Invalid Selection";
} else {
break;
}
} while ( true );
{
cin.clear();
//cin.ignore(numeric_limits<streamsize>::max(), '\n');
cout << "Please Re-Enter ( Entry Invalid )" << endl;
cout << "Enter Employee type: ";
}
if (EmployeeType != -1)
{
switch (EmployeeType)
{
case 1:
{
cout << "Enter Employee's Hourly rate: ";
while (!(cin >> HourlyRate))
{
cin.clear();
//cin.ignore(numeric_limits<streamsize>::max(), '\n');
cout << "Please Re-Enter ( Entry Invalid )" << endl;
cout << "Enter Employee's Hourly rate:";
}
cout << "Enter Employee's Hours Worked: ";
while (!(cin >> HoursWorked))
{
cin.clear();
//cin.ignore(numeric_limits<streamsize>::max(), '\n');
cout << "Please Re-Enter ( Entry Invalid )" << endl;
cout << "Enter Employee's Hours Worked: ";
}
}
Pay = HourlyRate * HoursWorked;
cout << fixed << setprecision(2);
cout << "Payment: $" << Pay << endl;
if (!cin)
{
break;
}
else
{
break;
}
return 0;
case 2:
{
cout << "Enter Employee's Annual Salary: ";
while (!(cin >> AnnualSalary))
{
cin.clear();
// cin.ignore(numeric_limits<streamsize>::max(), '\n');
cout << "Please Re-Enter ( Entry Invalid )" << endl;
cout << "Enter Employee's Annual Salary: ";
}
Pay = AnnualSalary / 52;
cout << fixed << setprecision(2);
cout << "Payment: $" << Pay << endl;
if (!cin)
{
break;
}
else
{
break;
}
}
return 0;
}
}
}