problems with char.

The beginning of my code executes fine, but problems occur when I try to receive user input for paycode. When debugging it doesn't allow me to enter a value. Any help or advice on how to fix this code would be much appreciated.
(Sorry if my logic doesn't make any sense!)








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

int main()
{
char employeeid[20] = "a";
int hoursworked = 0;
char paycode[20] = "a";
char insurancecode[20] = "a";
double grosspay = 0.0;
double overtime = 0.0;
double drate = 0.0;
double netpay = 0.0;
double FICA = 0.0;
double FMED = 0.0;
double SIT = 0.0;
double FIT = 0.0;
double insurancetax = 0.0;
double hourlypay = 0.0;
std::string employeename = "Some text";



cout<<"Please enter your employee name or type 'exit' to end the program." << endl;
std::getline(std::cin, employeename);
if (employeename == "exit")
{
return 0;
}

cout << "Please enter your employee id." << endl;

cin.get(employeeid, 20);
cin.ignore(80, '\n');

cout<<"Please enter your hours worked." << endl;
cin >> hoursworked;
while (cin.fail())
{
cin.clear();
cin.ignore(999, '\n');
cout << "That was not a vaild responce. Please enter another value." << endl;
cin >> hoursworked;

}

cout<<"Please enter your paycode." << endl;
cin.get(paycode, 20);
cin.ignore(80, '\n');

while ((paycode[20] != 'M') && (paycode[20] != 'C') && (paycode[20] != 'L'))
{
cin.clear();
cin.ignore(999, '\n');
cout << "Valid responces are M C L" << endl;
cin.get(paycode, 20);
cin.ignore(80, '\n');

}

cout<<"Please enter your insurance code." << endl;
cin.get(insurancecode, 20);
cin.ignore(80, '\n');

while ((insurancecode[20] != 'A') && (insurancecode[20] != 'B') && (insurancecode[20] != 'C'))
{
cin.clear();
cin.ignore(999, '\n');
cout << "Valid responces are A B C." << endl;

}

switch (paycode[20])
{
case 'M':
hourlypay = 27.50; break;
case 'C':
hourlypay = 19.50; break;
case 'L':
hourlypay = 10.35; break;
}

switch (insurancecode[20])
{
case 'A':
insurancetax = 25.00; break;
case 'B':
insurancetax = 15.00; break;
case 'C':
insurancetax = 0.00; break;
}



if ((hoursworked < 40) && (hoursworked >= 48))
{
overtime = (hoursworked - 40) * hourlypay * 1.5;
}

if (hoursworked < 48)
{
overtime = 8 * hourlypay * 1.5;
drate = (hoursworked - 48) * hourlypay * 2;
}

grosspay = hoursworked * hourlypay + overtime + drate;

FICA = grosspay * .062;
FMED = grosspay * .0145;
SIT = grosspay * .050;


if (grosspay < 350.00)
{
FIT = grosspay * .125;
}

else if ((grosspay >= 350.00) && (grosspay <= 1000.00))
{
FIT = grosspay * .22;
}

else if (grosspay > 1000.00)
{
FIT = grosspay * .2935;
}

netpay = grosspay - FIT - FICA - FMED - SIT - insurancetax;


system("CLS");
cout<<netpay<< endl;
system("pause");







}
Use the code tags please...
http://www.cplusplus.com/articles/jEywvCM9/
Topic archived. No new replies allowed.