/*A company pays its employees as managers (who receive a fixed weekly salary),
hourly workers (who receive a fixed hourly wage for up to the first 40 hours they
work and “time-and-a-half” 1.5 times their hourly wage for overtime hours
worked), commission workers (who receive 250 ETB plus 5.7 percent of their
gross weekly sales), or pieceworkers (who receive a fixed amount of money per
item for each of the items they produce each pieceworker in this company works
on only one type of item). Write a program to compute the weekly pay for each
employee. You do not know the number of employees in advance. Each type of
employee has its own pay-code: Managers have code C1, hourly workers have
code C2, commission workers have code C3 and pieceworkers have code C4.
Use more appropriate selection structure to compute each employee’s pay
according to that employee’s pay-code. The program should prompt the user (i.e.,
the payroll clerk) to enter the appropriate facts your program needs to calculate
each employee’s pay according to that employee’s pay-code. Finally, the
program prints the weekly pay of the employees in tabular format. Also the
program allows the user to search for specific record.*\
What I have tried:
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
string name[100], type, suffix, srch;
int fixed[100], work[100], price[100], coun;
char quit = '1';
int regular, par, length, srch_coun;
do{
first:
cout<< "Type of Worker (Worker Code): \n C1 - For the Manager\n C2 - For Hourly Work Plus Overtime\n C3 - For Salesman \n C4 - For Pieceworkers)\n ";
cout<< "Please Enter the work area code you want to access: ";
cin>>type;
if (coun + 1 ==1)
suffix="st";
else if (coun + 1 ==2)
suffix="nd";
else if(coun + 1 ==3)
suffix="rd";
else
suffix="th";
cout << coun + 1<<suffix<<" Employee's Data "<< endl;
if (type == "C1" || type == "c1"){
cout << "Employee(Manager's) Name: ";
getline(cin >> ws, name[coun]);
cout << "Income of the manager: ";
cin >> fixed[coun];
} else if (type == "C2" || type == "c2") {
cout << "Employee(Hourly worker's) Name: ";
getline(cin >> ws, name[coun]);
cout << "Hourly Pay: ";
cin >> fixed[coun];
cout << "Hourly Worked: ";
cin >> work[coun];
if(work[coun]<=40){
fixed[coun] = fixed[coun]*work[coun];
} else if(work[coun]>40){
regular=40*fixed[coun];
par=(work[coun]-40) * (1.5*fixed[coun]);
fixed[coun] = regular + par;
}
} else if (type == "C3" || type == "c3") {
cout << "Employee(Commission worker's) Name: ";
getline(cin >> ws, name[coun]);
cout << "Number of Sales Made: ";
cin >> fixed[coun];
cout << "Average Price of Each Sales: ";
cin >> price[coun];
fixed[coun] = 250 + (0.057*fixed[coun]*price[coun]);
} else if (type == "C4" || type == "c4") {
cout << "Employee(piece worker's) Name: ";
getline(cin >> ws, name[coun]);
cout << "Number of Item Produced: ";
cin >> fixed[coun];
cout << "Price of One Produced: ";
cin >> price[coun];
fixed[coun] = fixed[coun] * price[coun];
} else {
cout << "Enter a Valid Employee Code :| \n";
goto first;
}
coun++;
if (name[coun].length() > length)
length = name[coun].length();
cout<<"......................................................................................................."<<endl;
cout<<" Employee's Name \t Weekly Income "<<endl;
for(int i=0; i<coun; i++){
cout<<" " <<name[i] << setw(25-(name[i].length()))<<"\t";
cout<<fixed[i]<<endl;
}
cout<<"......................................................................................................."<<endl;
cout<<"Press 0 to quit! - To Continue Press Any Button ";
cin>>quit;
} while(quit!='0');
cout<<"......................................................................................................."<<endl;
cout<<"Search For Registered Employee...\n";
do{
cout<<"Search: ";
cin>>srch;
for(int i=0; i<coun; i++){
for(int j=0; j<3; j++){
if(srch[j]==name[i].at(j)){
cout<<"......................................................................................................."<<endl;
cout<<" Employee's Name \t Weekly Income "<<endl;
cout<<" " <<name[i] << setw(25-(name[i].length()))<<"\t";
cout<<fixed[i]<<endl;
cout<<"......................................................................................................."<<endl;
break;
}
}
}
srch_coun++;
} while (srch_coun<coun);
return 0;
}