Mar 16, 2011 at 11:35pm UTC
#include<iostream>
#include<fstream>
#include<iomanip>
using namespace std;
//Function prototype
double calcWage(double[], double[],);
void printWages (int [], double [], double [], double wage[])
void getEmployeeInfor(int [],double [], double [], int);
double getEmployeeInforID(int [],double[], double[],int);
void getEmployeeInforRate(int[], double[], double[], double [],int);
void getEmployeeInforHours(int[], double[], double[], double [],int);
void getEmployeeInforWage(int[], double[], double[], double [], int);
void selectionSort(int[], double[],double[],double[],int)
void Menu();
main ()
int SIZE[]=100;
int ID[];
double payrate[],hours[],wage[];
{
do
{
choice = Menu();
switch(choice)
{
case0:calcWge(payrate,hours);
break;
case1:
getEmployeeInfor(ID,payrate,hours,size);
char choice;
cout << "Do you want to calculate another employee's gross"
"wage? ";
cin >> choice;
if (choice == 'n')
break;
cout << "The result is reported to the file"
" \"employeeWages.dat\"." << endl;
case1:
getEmployeeInforID(ID,payrate,hours,size)
break;
case2:
getEmployeeInforRate(ID,payrate,hours,size)
break;
case3:
getEmployeeInhours(ID,payrate,hours,size)
break;
case4:
getEmployeeInforWage(ID,payrate,hours,size)
break;
}
return 0;
}
}
//*****************************************************
// This function ask the user to input his ID, *
// payrate, and the hours worked. *
//*****************************************************
void getEmployeeInfor (int ID[],double payrate[],double hours[], size)
{
while (1) {
cout << " Enter an employee's information by order of ID "
<< "number,rate,hours: " << endl;
cin >> ID >> payrate >> hours;
if(ID < 0 || payrate < 0 || hours < 0)
{
cout <<" You must enter a non negative valve. Try again!" << endl;
continue;
}
else
break;
}
}
//*****************************************************
// This function calculates one employee's *
// gross wage *
//*****************************************************
double calcWage( double rate[], double hours[])
{
double wage;
wage = rate[] * hours[];
return wage;
}
//*****************************************************
// This function prints an employee ID, *
// payrate,hours worked and *
// wages *
//*****************************************************
void printWages (int ID[], double rate[], double hours[], double wage[])
{
static ofstream out ("employeeWages.dat");
static int i = 0;
if(i == 0)
{
out.setf(ios::right);
out << setw (10) << "ID" << setw (20) << "Hourly Rate"
<< setw (15) << "Hours" << setw (20)<< "Wage" << endl;
out << "------------------------------------"
<< "-----------------------------" << endl;
i = 1;
}
out << fixed << setprecision(2);
out << setw (10) << ID << setw (20) << rate
<< setw (15) << hours << setw (20)<< wage << endl;
}
void dualSort(int ID[],double payrate[],double hours[],double wage[], int size)
{
int index_one, index_two;
int temp;
for ( index_one = 0; index_one < (size - 1); index_one++)
{
for(int index_two = index_one + 1; index_two < size; index_two++)
{
if (ID[index_one] < ID[index_two])
{
temp = ID[index_one];
ID[index_one] = ID[index_two];
ID[index_two] = temp;
temp = payrate[index_one];
payrate[index_one] = payrate[index_two];
payrate[index_two] = temp;
temp = hours[index_one];
hours[index_one] = hours[index_two];
hours[index_two] = temp;
temp = wage[index_one];
wage[index_one] = wage[index_two];
wage[index_two] = temp;
}
}
}
}
void showOrder(int ID[],double payrate[],double hours[],double wage[], int size)
{
cout << " ID \t Hourly rate \t hours \t wage";
for (int index = 0; index < num; index++)
{
cout << id[index] << "\t";
cout << setw(14) << payrate[index] << endl;
cout << setw(20) << hours[index] << endl;
cout << setw(26) << wage[index] << endl;
}
cout << endl;
void getEmployeeInforID (int ID[],double payrate[],double hours[], size)
{
}
void getEmployeeInforRate (int ID[],double payrate[],double hours[], size)
{
}
void getEmployeeInforhours (int ID[],double payrate[],double hours[], size)
{
}
void getEmployeeInforWage (int ID[],double payrate[],double hours[], size)
{
}
void Menu()
{
cout << \t\t Menu << endl;
<<" 1. Calculate gross wages for employees" endl;
<<" 2. Display employees' information to screen" endl;
<<" 3. Display employees' information to screen according"
"to the order of ID" << endl;
<<" 4. Display employees' information to screen according"
"to the order of hourly rate" << endl;
<<" 5. Display employees' information to screen according"
"the order of hours worked" << endl;
<<" 6. Display employees' information to screen according"
"the order of wage" << endl;
<<" 7.Quit the system" << endl;
<<"Please enter an option:" <<endl;
}
void selectionSort(int ID[], double rate[],double
hours[],double wage[],size)
{
}