Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ctime>
- #include <iostream>
- using namespace std;
- int GetSalary(int,int,int,int);
- int GetYearsOfService(int);
- int main()
- {
- int employeeId, hoursWorked, yearJoined, fullTime;
- cout << "Employee ID: ";
- cin >> employeeId;
- cout << "Hours Worked: ";
- cin >> hoursWorked;
- cout << "Year Joined: ";
- cin >> yearJoined;
- cout << "FullTime Status (0 for no, 1 for yes): ";
- cin >> fullTime;
- double salary = GetSalary(employeeId, hoursWorked, yearJoined, fullTime);
- double taxes = salary * 0.15;
- cout << endl << "Empolyee ID: " << employeeId << endl << "tFull time?: ";
- if (fullTime == 0)
- cout << "No";
- else
- cout << "Yes";
- cout << endl << "tHours worked: " << hoursWorked << endl << "tWages (after tax) for the month: $"
- << salary - taxes << endl << "tAmount withheld for tax: $" << taxes;
- return 0;
- }
- int GetSalary(int employeeId, int hoursWorked, int yearJoined, int fullTime) {
- double hourlyWage = 14;
- //Get the hourly wage
- int wage = 14;
- if( wage>=50 && wage < 100){
- wage += 1.25;
- }else if( wage < 160){
- wage += 2.0;
- }else{
- wage += 3.0;
- }
- double baseSalary = hourlyWage * hoursWorked;
- int yearsOfService = GetYearsOfService(yearJoined);
- //Check if any additional benefits/bonusses are to be paid
- if (fullTime == 1)
- {
- baseSalary += (35 *yearsOfService);
- baseSalary += 300;
- }
- else {
- if (yearsOfService > 5)
- baseSalary += (35 * yearsOfService);
- }
- return baseSalary;
- }
- int GetYearsOfService(int yearJoined) {
- time_t curTime = time(NULL);
- int elapsed = curTime / (365 * 24 * 60 * 60);
- return 1970 + elapsed - yearJoined;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement