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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
void GetData (string Namef[], int IdNumf[], float HoursWorkedf[], float HourlyRatef[], int &Indexf);
void ComputePay (float HoursWorkedf[], float HourlyRatef[], float GrossPayf[], int Indexf);
void PrintReport (string Namef[], int IdNumf[], float HoursWorkedf[], float HourlyRatef[], float GrossPayf[], int Indexf);
int menu();
const int MAXEMP = 10;
int main()
{
char again;
string Name[MAXEMP];
int IdNum[MAXEMP], choice, Index;
float HoursWorked[MAXEMP], HourlyRate[MAXEMP], GrossPay[MAXEMP];
do
{
switch (menu())
{
case 1:
cout<<"Enter Employee Data\n\n";
GetData (Name, IdNum, HoursWorked, HourlyRate, Index);
}
}while ((again != 'N') && (again != 'n'));
return 1;
}
void GetData (string Namef[], int IdNumf[], float HoursWorkedf[], float HourlyRatef[], int &Index)
{
int indexf = -1;
string FirstName, LastName;
char again;
string Name;
int IdNum;
do
{
indexf++;
again = 'y';
cout<<"Employee number "<<indexf + 1<<":\n";
cout<<"Please enter your first and last name seperated by a space:\t";
cin>>Namef[indexf];
cout<<"\nPlease enter your four digit ID number:\t";
cin>>IdNumf[indexf];
cout<<"\nPlease enter the ammount of hours worked:\t";
cin>>HoursWorkedf[indexf];
cout<<"\nPlease enter the hourly rate:\t";
cin>>HourlyRatef[indexf];
Index = indexf;
cout<<"Again?";
cin>>again;
} while ((again != 'n') && (again != 'N'));
return;
}
int menu()
{
int choice;
int ok = 1;
cout<<"\n\n\n";
cout<<"\t\tWelcome to the CSC 110 Payroll Program"<<endl;
cout<<"\t\t\tPlease choose from the following:"<<endl;
cout<<"\n\n\n";
cout<<"1. Enter Employee Data"<<endl;
cout<<"2. Compute Gross Pay"<<endl;
cout<<"3. Edit Employee Data"<<endl;
cout<<"4. Sort Employee Records"<<endl;
cout<<"5. Print Report"<<endl;
cout<<"6. Exit"<<endl;
cin>>choice;
do
{
if ((choice < 1) || (choice > 6))
{
cout<<"Invalid choice. Please try again.\n";
ok = 0;
system ("PAUSE");
system ("CLS");
}
}
while (!ok);
return choice;
}
|