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 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
|
#include<iostream>
#include<cstring>
#include<string>
#include<fstream>
#include"employee.h"
#include"manager.h"
using namespace std;
int main()
{
// Declaration of variable
string name, address, town, date, phone;
int id, postcode, worker, edit;
double hour, rate, gross, net;
int bypass = 1;
char *post;
int employeeCount = 0;
int managerCount = 0;
int totalCount = 0;
int another_employee = 0;
char* strEmployee = "Employee";
char* strManager = "Manager";
Employee employee[100]; // Declaration of class array
Manager manager[100];
employee[0].resetData(); // Reset counter
if (bypass == 1)
{
cout << "Welcome to you Employee Payslip Generator:" << endl;
do
{
cout << "Please enter your employee's name : ";
getline (cin,name);
cout << "Employee's staff ID no. : ";
cin >> id;
cout << "Employee's Position : ";
cin >> post;
cout << "Employee's Worker : ";
cin >> worker;
cin.ignore();
cout << "Employee's address : ";
getline (cin,address);
cout << "Town : ";
getline (cin,town);
cout << "Postcode : ";
cin >> postcode;
cin.ignore();
cout << "Employee's contact no. : ";
getline (cin,phone);
cout << "Payslip Date(month year) : ";
getline (cin,date);
cout << "Number of hours worked this week(hour): ";
cin >> hour;
cout << "Employee's Payrate(per hour) : RM ";
cin >> rate;
cout << endl;
if (strcmp(strEmployee,post) == 0)
{
employee[employeeCount-1].employeeDetail(name, id, post, address, town, postcode, phone, date, hour, rate);
employee[employeeCount-1].printEmployeeData();
employee[0].setEmployeeTotalGrossPay(employee[employeeCount-1].getEmployeeGrossPay());
employee[0].setEmployeeTotalNetPay(employee[employeeCount-1].getEmployeeNetPay());
++employeeCount;
}
else if (strcmp(strManager,post) == 0)
{
manager[employeeCount-1].managerDetail(name, id, post, address, town, postcode, phone, date, hour, rate, worker);
manager[employeeCount-1].printEmployeeData();
employee[0].setEmployeeTotalGrossPay(manager[employeeCount-1].getEmployeeGrossPay());
employee[0].setEmployeeTotalNetPay(manager[employeeCount-1].getEmployeeNetPay());
++managerCount;
}
cout << "Do you want to process another employee?" << endl;
cout << "Enter 1 for yes and 0 for no: ";
cin >> another_employee;
cin.ignore();
cout << endl;
cout << "_______________________________________________" << endl;
}while(another_employee==1);
totalCount = employeeCount + managerCount;
employee[0].setTotalCount(totalCount);
}
else
cout << "Wrong Access." << endl;
do{
cout << "Do you want to edit data?" << endl;
cout << "Enter 1 for yes and 0 for no: ";
cin >> edit;
if (edit == 1)
{
int category;
cout << "Please choose the category to access." << endl;
cout << "1. Manager" << endl;
cout << "2. Employee" << endl;
cin >> category;
if (category == 1)
manager[0].editData(manager);
else if (category == 2)
employee[0].editData(employee);
else if (category > 2 || category < 1)
cout << "Invalid category." << endl;
}
else
employee[0].printCompanyData();
}while(edit == 1);
manager[0].exportData(manager,managerCount);
employee[0].exportData(employee,employeeCount);
system("pause");
return 0;
}
|