1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
#include <string>
#include <iostream>
#include <iomanip>
using namespace std;
void GetData( string[], string[], double[],double[]);
void CalcData(int, int, double[],double[],double[], double[]);
void PrintData(string ename[4], string etitle[4], double curr_year[], double new_year[]);
int main()
{
int const hours = 40;
int const weeks = 52;
string ename[4];
string etitle[4];
double ewage[4];
double inc[4];
double curr_year[4];
double new_year[4];
GetData(ename,etitle, ewage, inc);
CalcData(hours, weeks, ewage, inc,curr_year, new_year);
PrintData(ename, etitle, curr_year, new_year);
cout<<endl; system("PAUSE");
return 0;
}
/* Function Definitions */
void GetData(string fename[], string fetitle[], double fewage[],double finc[])
{
for (int i = 0; i< 4; i++)
{
cout<<"Please enter Employee Name: "<<endl;
getline(cin,fename[i]);
cout<<"Please enter Employee Title: "<<endl;
getline(cin,fetitle[i]);
cout<<"Please enter Employee Hourly Wage: $"<<endl;
cin>>fewage[i];
cout<<"Please enter Employee Wage Increase: % "<<endl;
cin>>finc[i];
cin.ignore(80,'\n');
}
}
void CalcData(int hours, int weeks, double fewage[],double finc[],double fcurr_year[], double fnew_year[])
{
for (int i=0; i<4; i++)
{
int hours = 40;
int weeks = 52;
fcurr_year[i] = fewage[i] * hours * weeks;
fnew_year[i] = fcurr_year[i] * (( finc[i] + 100 ) / 100);
}
}
void PrintData(string fename[4], string fetitle[4], double fcurr_year[], double fnew_year[])
{
cout << left << setw(20)<<"Name";
cout << left << setw(30)<<"Title";
cout << left << setw(15)<<"Current Income";
cout << left << setw(15)<<"New Income";
cout << "\n" << endl;
// code goes here to sort??
for (int i=0; i <4; i++)
{
cout << fixed;
cout << setprecision(2);
cout << left << setw(20) << fename[i];
cout << left << setw(30) << fetitle[i];
cout << left << setw(15) << fcurr_year[i];
cout << left << setw(15) << fnew_year[i];
cout << "\n" << endl;
}
}
|