Search This Blog

Friday, October 21, 2011

Payroll System Code

#include<iostream.h>
#include<conio.h>
#include<cstring.h>
#include<fstream.h>
int dtr();
int  main()
{
string fname,lname,id,idnum,pos;
ifstream fin("name.txt",ios::in);
cout<<"enter id number:";
cin>>idnum;
for(int x=0;x<5;x++)
{
getline(fin,id,',');
getline(fin,fname,'_');
getline(fin,lname,',');
getline(fin,pos);
if(idnum==id)
{
cout<<"\nname:"<<fname<<lname;
cout<<"\nposition:"<<pos;
}
}
dtr();
getch();
return 0;
}

int dtr()
{
 string hr1,hr2,min1,min2;
 string ohr1,ohr2,omin1,omin2,o,h;
 int subhr1,subhr2,submin1,submin2,min,hr,modmin,thr=0,tmin=0,modtmin,dtmin,thrs=0;
 int subohr1,subohr2,subomin1,subomin2,omin,ohr,modomin,othr=0,otmin=0,modotmin,dotmin,othrs=0;
 string day[]={"monday","tuesday","wednesday","thursday","friday"};
  for(int x=0;x<5;x++)
  {
  cout<<"\ntime in for:"<<day[x];
  cout<<"\n===================================================";
  cout<<"\nIN:";
  getline(cin,hr1,':');
  getline(cin,min1);
  cout<<"\nOUT:";
  getline(cin,hr2,':');
  getline(cin,min2);
  subhr1=atoi(hr1.c_str());
  subhr2=atoi(hr2.c_str());
  submin1=atoi(min1.c_str());
  submin2=atoi(min2.c_str());
  min=(60-submin1)+submin2;
  hr=((subhr2-2)-subhr1)+min/60;
  modmin=min%60;
  thr=thr+hr;
  tmin=tmin+modmin;
    if(x==4)
    {
    dtmin=tmin/60;
    modtmin=tmin%60;
    thrs=dtmin+thr;
 }
  cout<<"Overtime? yes/no: "<<"\n";
  cin>>o;
  if(o=="yes")
  {
    cout<<"\ntime in for overtime:";
    cout<<"\nIN:";
  getline(cin,ohr1,':');
  getline(cin,omin1);
  cout<<"\nOUT:";
  getline(cin,ohr2,':');
  getline(cin,omin2);

  subohr1=atoi(ohr1.c_str());
  subohr2=atoi(ohr2.c_str());
  subomin1=atoi(omin1.c_str());
  subomin2=atoi(omin2.c_str());

  omin=(60-subomin1)+subomin2;
  ohr=((subohr2-1)-subohr1)+omin/60;
  modomin=omin%60;

  othr=othr+ohr;
  otmin=otmin+modomin;
      }
    if(x==4)
    {
    dotmin=otmin/60;
    modotmin=otmin%60;
    othrs=dotmin+othr;
    }


 }

cout<<"\ntotal time rendered:"<<thrs<<" "<<"hours and"<<" "<<dtmin<<" "<<"minutes";
cout<<"\ntotal overtime rendered:"<<othrs<<" "<<"hours and"<<" "<<modotmin<<" "<<"minutes";
}