i have to make a program to calculate certain wages and salaries for different employees.. my question is how do i let the user input as many different employees as they want and for me to output them? because now when i do it, it just keeps replacing it with the new data and only outputs the last one i entered.. here is the code i have so far...its kind of confusing to read this way..if u IM me on aol ill email it to ..thanks for all help
#include <iostream.h>
#include <iomanip.h>
#include <conio.h>
const int SIZE=20, ALLWD_HRS=40;
char last_name[SIZE], first_name[SIZE];
char exit;
int emp_type, pieces;
double st_tax, fed_tax;
const double STATE_TAX=.06, FEDERAL_TAX=.12, HRLY_WAGE=12.50, TIME_HALF=18.75;
const double MANGR_ST_TAX=52.50, MANGR_FED_TAX=157.50, MANGR_GROSS=875.00;
const double MANGR_SAL=717.50, PIECES_COST=1.125;
double total_gross_salary=0, hrs_worked=0, over_time=0,wage=0;
double gross=0, salary=0;
int main()
{
cout.precision(2);
cout<<"This program will calculate a person's weekly gross salary based\n"
"on his job type. It will then calculate the state and federal taxes\n"
"and then output the person's final salary. Also it will output the \n"
"total gross salary of all the salaries entered.\n\n\n\n";
do
{
cout<<"Please enter the first name of the employee: ";
cin.getline(first_name, SIZE);
cin.ignore(80, '\n');
cout<<"\n\nPlease enter the last name of the employee: ";
cin.getline(last_name, SIZE);
cin.ignore(80, '\n');
clrscr();
cout<<"\n\n\n\n";
cout<<" ***********************\n";
cout<<" **EMPLOYEE CODE CHART**\n";
cout<<" ***********************\n";
cout<<" ** 1= Manager **\n";
cout<<" ** 2= Hourly Worker**\n";
cout<<" ** 3= Piece Worker **\n";
cout<<" ***********************\n";
cout<<"\n\nPlease enter employee type by using the code for each type: ";
cin>>emp_type;
switch(emp_type)
{
case 1:
{
gross=MANGR_GROSS;
salary=MANGR_SAL;
st_tax=MANGR_ST_TAX;
fed_tax=MANGR_FED_TAX;
total_gross_salary=MANGR_GROSS+total_gross_salary;
break;
}
case 2:
{
cout<<"\n\nEnter number of hours worked this week: ";
cin>>hrs_worked;
if (hrs_worked > ALLWD_HRS)
{
over_time=(hrs_worked-ALLWD_HRS)*(TIME_HALF);
gross=wage+over_time;
}
else
{
gross=(hrs_worked*HRLY_WAGE);
}
total_gross_salary=gross+total_gross_salary;
st_tax=gross*STATE_TAX;
fed_tax=gross*FEDERAL_TAX;
salary=gross-(st_tax+fed_tax);
break;
}
case 3:
{
cout<<"\n\nEnter the number of pieces produced this week ";
cin>>pieces;
gross=pieces*PIECES_COST;
total_gross_salary=gross+total_gross_salary;
st_tax=gross*STATE_TAX;
fed_tax=gross*FEDERAL_TAX;
salary=gross-(st_tax+fed_tax);
break;
}
default:
{
cout<<"\n\nNot a correct employee code ";
break;
}
}
cout<<"\n\nDo you want to continue?: ";
cin>>exit;
}while (exit != 'N'||exit != 'n ');
cout<<"\n\n\n\n";
cout<<"Name Emp. Pieces Hrs. State Fed. Gross Salary\n";
cout<<" Type Wkd. Tax Tax \n";
cout<<"==============|===|=======|=====|=======|== ===|==========|========|\n";
cout<<setw(6)<<last_name<<setw(6)<<first_name<<set w(4)<<emp_type<<setw(4)<<pieces;
cout<<setw(4)<<hrs_worked<<setw(4)<<st_tax<<setw(4 )<<fed_tax<<setw(4)<<'$'<<gross;
cout<<setw(4)<<'$'<<salary'\n';
return 0;
}