i have a program that uses a do while loop to repetitively ask certain question and i need to output all the information that the user inputs for those question in a organized chart. my problem is it only outputs the last set of data i input.How do i output the other data i have already inputted?
Code:
#include <iomanip>
#include <string>
#include <iostream>
using namespace std;
int main ()
{
int yearsofservice,yearhired,oldsalary,code;
int numfaculty,totsalaryincrease,avgsalaryincrease;
int facultycounter=1;
double newsalary;
double salaryincrease;
const int YEAR=2007;
string fname;
string lname;
cout<<"How many faculty members are you inputting?:";
cin>>numfaculty;
do
{
cout<<"Input the members name:";
cin>>fname>>lname;
cout<<"Input the members year hired:";
cin>>yearhired;
cout<<"Input the members old salary:";
cin>>oldsalary;
cout<<"Input the members code:";
cin>>code;
switch (code)
{
case 1: salaryincrease=oldsalary*(.03);
break;
case 2: salaryincrease=oldsalary*(.05);
break;
case 3: salaryincrease=oldsalary*(.08);
break;
default: cout<<"You did not type any code in!!!";
}
newsalary=salaryincrease+oldsalary;
yearsofservice=YEAR-yearhired;
}while (facultycounter++ <numfaculty);
cout<<"Robert Dobler\n\n\n";
cout<<setw(57)<<"FAILNONE UNIVERSITY FACULTY SALARY REPORT FOR "<<YEAR<<endl<<endl<<endl<<endl;
cout<<setw(10)<<"FACULTY"<<setw(17)<<"YEARS OF"<<setw(11)<<"OLD"<<setw(11)<<"NEW"<<setw(17)<<"SALARY"<<endl;
cout<<setw(8)<<"NAME"<<setw(19)<<"SERVICE"<<setw(13)<<"SALARY"<<setw(11)<<"SALARY"<<setw(16)<<"INCREASE"<<endl;
cout<<setw(10)<<"-------"<<setw(17)<<"--------"<<setw(13)<<"------"<<setw(11)<<"------"<<setw(16)<<"--------"<<endl;
cout<<fname<<lname<<setw(12)<<yearsofservice<<setw(16)<<oldsalary<<setw(11)<<newsalary<<setw(14)<<salaryincrease<<endl;
return 0;
}