cout << "Enter the PayCode type as one of the following: -\n";
cout << " H - Hourly\n";
cout << " P - Piece Work\n";
cout << " C - Commission\n";
cout << " S - Salary\n";
cout << "Enter your choice :";
cin >> paycode;
// select case of value entered
switch (paycode)
{
case 'H':
case 'h':
paynum = 1 ;
break;
case 'P':
case 'p':
paynum = 2;
break;
case 'C':
case 'c':
paynum = 3;
break;
case 'S':
case 's':
paynum = 4;
break;
default:
cout << "Please enter a valid selection." << endl;
return paynum;
}
// end of switch structure
// start of finding amount of pay for the person and entering values
if (paynum = 1)
{
cout << "Please enter the rate:";
cin >> rate;
cout << "Please enter the hours worked:";
cin >> hours;
pay = rate * hours;
}
else
{
if (paynum = 2)
{
cout << "Please enter the rate:";
cin >> rate;
cout << "Please enter the number of pieces:";
cin >> pieces;
pay = rate * pieces;
}
else
{
if (paynum = 3)
{
cout << "Please enter the amount of commission:";
cin >> comm;
cout << "Please enter the number of sales:";
cin >> sales;
pay = comm * sales;
}
else
{
if (paynum = 4)
{
cout << "Please enter the salary:";
cin >> salary;
pay = salary;
}
else
{
cout << "Please enter a valid selection." ;
}
}
}
}
cout << endl << "The amount of pay for " << name << " is " << pay << endl;
system ("pause");
}
// output the value determineed in the switch/case