here is the scenario...
i want to register employee number, employee name and salary...
and then i want to add date, no of hours, rate and compute for the total by multiplying "no of hrs" and "rate"
and computing all the input totals to get the Gross pay by multiplying "salary" and "totals".
thanks in advance!
heres the coCode:#include <windows.h> #include<iostream.h> #include<string.h> #include<conio.h> #include<stdio.h> #include <cstring> void add_DTR(); char empneym[50][30]; char empno[50][30]; double bsalary[30]; char deyt[50][10]; double reyt[50]; int nofH[50]; double tot[50]; int i=0; int a=0; int b=0; int d=0; int opt_main; char opt_add; char opt_dtr; char *ver_empno; double add; void main() { system("cls"); do{ system("cls"); cout<<"Main Menu"<<endl; cout<<"[0] Exit"<<endl; cout<<"[1] Add Employee"<<endl; cout<<"[2] Add Dtr"<<endl; cout<<"[3] View Employee"<<endl; cout<<"\n"; cout<<"Choose option: ";cin>>opt_main; switch(opt_main){ case 1: do{ system("cls"); cout<<"Add Employee"<<endl; cout<<"\n"; cout<<"Enter Emp. No.: ";cin>>empno[i]; cout<<"Enter Emp. Name.: ";cin>>empneym[i]; cout<<"Enter Basic Salary: ";cin>>bsalary[i]; i++; cout<<"Enter another? <y/n>: ";cin>>opt_add; }while(opt_add!='n'); break; case 2: do{ system("cls"); cout<<"Add DTR"<<endl; cout<<"\n"; cout<<"Enter Employee No.: ";cin>>ver_empno; for(a=0;a<i;a++) { if(strcmp(ver_empno, empno[a])==0) //if(ver_empno==empno[a]) { cout<<"Employee No.: "<<empno[a]<<endl; cout<<"Employee Name: "<<empneym[a]<<endl; cout<<"Basic Salary: "<<bsalary[a]<<endl; } } add_DTR(); cout<<"Enter another? <y/n>: ";cin>>opt_dtr; }while(opt_dtr!='n'); break; case 3: system("cls"); cout<<"View Employee DTR"<<endl; cout<<"\n"; cout<<"Enter Employee No.: ";cin>>ver_empno; for(int c=0;c<i;c++) { if(strcmp(ver_empno, empno[c])==0) { cout<<"Employee No.: "<<empno[c]<<endl; cout<<"Employee Name: "<<empneym[c]<<endl; cout<<"Basic Salary: "<<bsalary[c]<<endl; cout<<"\n"; cout<<"Date Hours weekend Rate Total"<<endl; cout<<"=============================================="; for(d=c;d<b;d++) { tot[d]=nofH[d]*reyt[d]; cout<<deyt[d]<<" "<<nofH[d]<<" "<<reyt[d]<<" "<<tot[d]<<endl; add=add+tot[d]; } } cout<<"\n"; cout<<"Gross Pay: "<<bsalary[c]+add; getch(); } break; } }while(opt_main!=0); } void add_DTR() { cout<<"\n"; cout<<"ADD DTR to Employee"<<endl; cout<<"Enter Date: ";cin>>deyt[b]; cout<<"No. of Hours: ";cin>>nofH[b]; cout<<"Enter Rate Per Hours :";cin>>reyt[b]; b++; getch(); }




Reply With Quote