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 99 100 101 102 103 104 105 106 107 108 109
|
void Menu(int MenuSelection, bool valid, string &EmployeeName, string &FirstName, string &LastName, int &EmployeeNumber, double &Hours, double &PayRate, char &UnionCode){
cout << "Payroll Maintenance Program" << endl;
cout << " Main Menu" << endl;
cout << endl;
cout << " 1. Add a Record" << endl;
cout << " 2. Display a Record" << endl;
cout << " 3. Display the File" << endl;
cout << " 4. Modify a Record" << endl;
cout << " 5. Delete a Record" << endl;
cout << " 6. Exit Program" << endl;
cout << endl;
cout << " Enter your selection (1-6)-> ";
cin >> MenuSelection;
cout << endl;
while (!valid){//verifies only menu numbers 1-6 are typed in
if (MenuSelection < 7 && MenuSelection >0){
valid = true;
}
else {
cout << "Invalid Input, Please Enter a Number 1-6 Only ";
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
cin >> MenuSelection;
cout << endl;
}
}
if (MenuSelection == 1){
GetInput(EmployeeName, FirstName, LastName, EmployeeNumber, Hours, PayRate, UnionCode);
Menu(MenuSelection, valid, EmployeeName, FirstName, LastName, EmployeeNumber, Hours, PayRate, UnionCode);
}
if (MenuSelection == 2){
cout << "Display Record" << endl;
}
if (MenuSelection == 3){
cout << "Display File" << endl;
}
if (MenuSelection == 4){
cout << "Modify" << endl;
}
if (MenuSelection == 5){
cout << "Delete" << endl;
}
if (MenuSelection == 6){
cout << "Exit" << endl;
}
}
void GetInput(string &EmployeeName, string &FirstName, string &LastName, int &EmployeeNumber, double &Hours, double &PayRate, char &UnionCode){
cout << "Enter Employee's First and Last Name: ";
cin >> FirstName;
cin >> LastName;
cout << endl;
EmployeeName = LastName + ", " + FirstName;
cout << "3 Digit Employee #: ";
cin >> EmployeeNumber;
cout << endl;
cout << "Hours Worked: ";
cin >> Hours;
while (Hours > 60){ //Hour verification, must be between 0.0 - 60.0
cout << endl;
cout << "Hours must be between 0.0 and 60.0" << endl;
cout << "Please Enter Hours Again: ";
cin >> Hours;
cout << endl;
}
cout << "Pay Rate: $";
cin >> PayRate;
while (PayRate < 7.50 || PayRate > 45.00){ //Pay Rate verification, must be between $7.50 and $45.00
cout << endl;
cout << "Pay rate must be between $7.50 and $45.00" << endl;
cout << "Please Enter Pay Rate Again: $";
cin >> PayRate;
cout << endl;
}
cout << "Union Code(A,B,C): ";
cin >> UnionCode;
while (UnionCode != 'A' && UnionCode != 'B' && UnionCode != 'C'){ //Union Code verification, must be A, B, or C
cout << endl;
cout << "Union Code can only be A, B, or C" << endl;
cout << "Please Enter Union Code Again: ";
cin >> UnionCode;
cout << endl;
}
cout << endl;
ofstream myfile("Employee_Data.txt", fstream::app);
myfile << "Name: " << EmployeeName << endl;
myfile << "Employee Number: " << EmployeeNumber << endl;
myfile << "Union Code: " << UnionCode << endl;
myfile.precision(2);
myfile.setf(ios::fixed);
myfile.setf(ios::showpoint);
myfile << "Hours: " << Hours << endl;
myfile << "Rate: $" << PayRate << endl;
myfile.close();
cout << "Record Has Been Added" << endl;
cout << endl;
}
|