0

Hello all:

I've been reading up on C++, which seems pretty cool. In my office, the HR representative has to manually calculate an employees vacation & sick time. So I was thinking if it's possible to create a program for her to help her out a bit. This is what I'm trying to accomplish with the program:

  1. Program should be able to tell if an employee is elegible for paid sick days.
  2. Should be able to tell if an employee is elegible for paid vacation.
  3. If 'yes', how many days and what are their remaining balances after manager has approved those days.

These are the conditions of the sick/vacation policy:
1. Each employee is granted 12 paid sicks days every year, but aren't carried over into the new year.
2. We consider a 'year' of employment on the anniversary that the employee has been working there.
3. Sick days to be paid : A formula that can provide the figure, in days with the following stipulations: (a) after an employee’s one year anniversary, they’re entitled to 12 days paid sick leave (b) during the first 12 months of employment and has worked not less than 110 days, employee may be granted leave with pay at a rate of 1 paid sick day for every 22 days one which employee worked) if the person isn’t entitled to sick pay, based on above criteria, then the program just says "0".
4. Vacation days to be paid :A formula that can provide the figure, in days with the following stipulations: (a) a worker who has worked more than 220 days in any year of employment, is entitled to 14 days of vacation for that year: or (b) A worker who has worked more than 110 days but not more than 220 days in any year of employment, is entitled to one day vacation leave for every 22 days on which he/she has worked (c) a worker with 6 or more years of service, who has worked more than 220 days in any year of employment, is entitled to 3 normal workings weeks of vacation leave for that year (d) you can’t carry vacation over beyond the third year of employment (e) public holidays cannot be counted in days of vacation leave.

I've started to type the code, but I'm unsure of the following:
1. Employees are entitled to their vacation days by accrual/based on the number of days counting from their Date of Hire. For example, if my date of hire is January 01, 2012...then on December 31, 2012 I'd qualify for my full 14 days...then january 01, 2013 (1 year anniversary, i'd start accruing for my 2013/2014 vacation ect...how will the code/program know the number of days, from the date of hire, to the current date (when I'm processing payroll)?

I'd appreciate any guidance/assistance:

#include <iostream>
#include <string>
#include <cmath>
#include <ctime>


using namespace std;

int main ()
{

  char choice;
  int DOH; // employee's date of hire
  int avsickdays = 0;// available sick days based on HR log (manually inputed)
  int avvacdays = 0; // available vacation days based on HR log (manually inputed)
  int appsick = 0; // approved sick days by manager (manually inputed)
  int appvac = 0; // approved vacation days by manager (manually inputed)
  int remsick = (avsickdays - appsick); // remainding sick days
  int remvac = (avvacdays - appvac); // remainding vacation days


  cout << "Welcome to payroll calculator"<<endl<<endl; 

  cout << "Are you calculating vacation? " ; // Y = Yes N = No

  cin >> choice;

  if (choice == 'N' || choice == 'n' )
  cout <<"Let's move on to calculate sick time"<<endl;

  {
  cin >> appsick;
  if ((appsick + avsickdays)>14)
  cout << "You have exceeded the number of entitled sick days!"<<endl;
  cout <<endl;
  }     

  cin >> appvac;

  cout << "Your remainding vacation days are "<<endl;
  cout << remvac;
  cout << endl;

  cout << "Your remainding sick days are "<<endl;
  cout << remsick;
  cout << endl;
  return 0;
}
2
Contributors
1
Reply
25
Views
3 Years
Discussion Span
Last Post by Ancient Dragon
0

how will the code/program know the number of days, from the date of hire, to the current date (when I'm processing payroll)?

Use functions in time.h (or ctime). You know the date of hire, so populate a struct tm with the day, month and year, zero out all other fields, then call mktime() to convert the structure to time_t variable (usually it's an unsigned int). Call time() to get the time_t value of the current date. Then all you do is call difftime() to find out the difference between the two.

Here is a simple example.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.