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 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
|
/* Program Name: Payroll3.cpp
Description:
Name: Class No.: 2441
Date: 02/25/08 Dev-C++
*/
//********************************** Includes
#include <cfloat>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cctype>
#include <iomanip>
#include <cmath>
#include <fstream>
#include <string>
#include <ctime>
#include <conio.h>
#include <windows.h>
#include <sstream>
#define cls system("cls")
#define frz system("pause");
#define yl system("color 0e");
using namespace std;
//********************************** Type definitions
//********************************** Function Prototypes
ifstream infile("f:\\paydata3.txt");
//********************************** Main Function
int main()
{
time_t t;
time(&t);
yl;
int i, C, M, count, total ;
string office, depend, hrrate, wkhrs, otwkhr;
stringstream strval1, strval2, strval3, strval4;
double gross=0, net, fed, fica, city, dues, totgross, totfed, totfica,
tothours, sswkhrs, sshrrate, ssdepend, totovthrs, ssotwkhrs;
count = 0;
total = 0;
totovthrs=0;
string text = "";
string first = "";
string last = "";
string empun = "";
string empid = "";
cout << " Payroll3. cpp " << ctime(&t) << endl << endl;
cout << fixed << showpoint << setprecision(2);
cout << "Emp Number " <<"First Name " << "Last Name " << "Hours "
<< "Rate " << "Overtime " << "Gross " << "Fed Tax " << "FICA "
<< "City Tax " << "Union Dues " << "Net Pay " << endl;
if (!infile)
{
cout << "An error has occurred while opening the file!" << endl;
frz;
}//end for infile
while (!infile.eof())
{
getline(infile, text);
infile.ignore(80,'\n');
count++;
first = text.substr(15,10);
last = text.substr(0,15);
office = text.substr(25,1);
empun = text.substr(26,1);
empid = text.substr(27,5);
wkhrs = text.substr(32,4);
hrrate = text.substr(36,5);
depend = text.substr(41,2);
otwkhr = text.substr(43,4);
strval1 << wkhrs;
strval1 >> sswkhrs;
strval2 << hrrate;
strval2 >> sshrrate;
strval4 << otwkhr;
strval4 >> ssotwkhrs;
cout << ssotwkhrs << endl;
gross = ((sswkhrs * sshrrate) + ((1.5 * sshrrate) * ssotwkhrs));
strval3 << depend;
strval3 >> ssdepend;
fed = (( gross - (17 * ssdepend))*.1834);
if (office=="C"){
city = (gross * .04);
}
else{
city = (gross * 0.00);
}
if (empun=="M"){
dues = (gross * .0473);}
else{
dues = (gross * 0.00);}
fica = (gross * .07650);
net = (gross -(fed + fica + city + dues));
totgross = totgross + gross;
totfed = totfed + fed;
totfica = totfica + fica;
tothours = tothours + sswkhrs;
totovthrs += ssotwkhrs;
cout << setw(8) << empid << setw(15) << first << setw(15) << last << setw(6)
<< wkhrs << setw(8) << hrrate << setw(8)<< otwkhr << setw(8) << gross
<< setw(8) << fed << setw(6) << fica << setw(10) << city << setw(10)
<< dues << setw(8) << net << endl << endl;
}//end while
cout << fixed << showpoint << setprecision(2);
cout << left << setw(33) <<"Number of employees processed = "
<< count << endl;
cout << left << setw(33) << "Total Gross Pay = "
<<totgross << endl;
cout << left << setw(33) <<"Total Federal Tax = "
<<totfed << endl;
cout << left << setw(33) << "Total Hours Worked = "
<< tothours << endl;
cout << left << setw(33) << "Total Overtime Hours Worked = "
<< totovthrs << endl;
frz;
infile.close();
// print.close();
return 0;
} // end of main function
//********************************** Function Definitions
|