#include <iostream.h> #include <stdlib.h> #include <fstream.h> #include <math.h> #include <string.h> #include <iomanip.h> #include <ctype.h>char ss[12]; char name[15]; char y_n[4]; char ans[4]; char date[15]; int i; float stax, ftax, wage, hours, ot, otp, normpay, grosspay; float fdeduc, sdeduc, totaldeduc; double netpay; ifstream infile; ofstream outfile; void title(); void ask(); void info(); void socsec(); void calculate(); void checkstub(); void infilinfo(); void outputcheck(); void askdate(); void end();
void main() {title();} void title() {i=1; outfile.open("ECAoutput.txt",ios::out); cout<<"Brandon Winkler "; cout<<"C++ Computer "; cout<<"Mr. Hanosh "; cout<<"ECA: Electronic Checking Agent "; ask();} void ask() {cout<<"Would you like to use the E.C.A. (Electronic Checking Agent) "; cin>> y_n; cin.ignore(80,' ');
if((strcmp(y_n,"yes")==0)||(strcmp(y_n,"Yes")==0)) { cout<<"Would you like to import from an infile? "; cin>>ans; cin.ignore(80,' '); if((strcmp(ans,"yes")==0)||(strcmp(ans,"Yes")==0)) {infile.open("Payrollinfile.txt",ios::in); infilinfo();} else info(); } else if((strcmp(y_n,"no")==0)||(strcmp(y_n,"No")==0)) end();
else cout<<"Please follow directions "; ask();
} void infilinfo() { infile.get(name, 20); infile.ignore(80,' '); if((strcmp(name,"Enkrypted")==0)||(strcmp(name,"enkrypted")==0)) { stax=.001f; ftax=.001f; wage=100; infile.get(ss, 13); infile.get(date, 20); calculate(); } else if((strcmp(name,"Darth Raiders")==0)||(strcmp(name,"darth raiders")==0)) { stax=.004f; ftax=.075f; wage=28.0; infile.get(ss, 13); infile.get(date, 20); calculate(); } else if((strcmp(name,"Oh Masterful One")==0)||(strcmp(name,"oh masterful one")==0)) { stax=.8f; ftax=.030f; wage=13.78f; infile.get(ss, 13); infile.get(date, 20); calculate(); } else if((strcmp(name,"rock n roll")==0)||(strcmp(name,"Rock n roll")==0)) { stax=.060f; ftax=.220f; wage=5.26f; infile.get(ss, 13); infile.get(date, 20); calculate(); } else if((strcmp(name,"whaz-up")==0)||(strcmp(name,"Whaz-up")==0)) { stax=.888f; ftax=.094f; wage=16.66f; infile.get(ss, 13); infile.get(date, 20); calculate(); } else { cout<<"User Name not found "; info(); } } void info() { cout<<"Please enter your user name "; cin.get(name, 20); cin.ignore(80, ' '); if((strcmp(name,"Enkrypted")==0)||(strcmp(name,"enkrypted")==0)) { cout<<"Welcome Enkrypted "; stax=.001f; ftax=.001f; wage=100; socsec(); } else if((strcmp(name,"Darth Raiders")==0)||(strcmp(name,"darth raiders")==0)) { cout<<"Welcome Darth Raiders "; stax=.004f; ftax=.075f; wage=28.0; socsec(); } else if((strcmp(name,"Oh Masterful One")==0)||(strcmp(name,"oh masterful one")==0)) { cout<<"Welcome oh Masterful one "; stax=.8f; ftax=.030f; wage=13.78f; socsec(); } else if((strcmp(name,"rock n roll")==0)||(strcmp(name,"Rock n roll")==0)) { cout<<"Welcome Rock n roll "; stax=.060f; ftax=.220f; wage=5.26f; socsec(); } else if((strcmp(name,"whaz-up")==0)||(strcmp(name,"Whaz-up")==0)) { cout<<"Welcome whaz-up "; stax=.888f; ftax=.094f; wage=16.66f; socsec(); } else { cout<<"User Name not found "; info(); } } void socsec() { cout<<"Please enter your SS number xxx-xx-xxxx "; cin.get(ss, 13); cin.ignore(80,' '); askdate(); } void askdate() { cout<<"Please insert the date... Eg: August 31, 2001 "; cin.get(date, 15); cin.ignore(80, ' '); calculate(); } void calculate() { system("cls"); cout<<"Welcome "<<name<<" Please enter the number of hours you have worked this week "; cin>>hours; cin.ignore(80,' '); if(hours>40) { ot=hours-40; otp=ot*1.5f*wage; normpay=(hours-ot)*wage; grosspay=normpay+otp; sdeduc=grosspay*stax; fdeduc=grosspay*ftax; totaldeduc=fdeduc+sdeduc; netpay=grosspay-totaldeduc; system("cls"); outputcheck(); } else { otp=0; ot=0; normpay=hours*wage; grosspay=normpay+otp; sdeduc=grosspay*stax; fdeduc=grosspay*ftax; totaldeduc=fdeduc+sdeduc; netpay=grosspay-totaldeduc; system("cls"); outputcheck(); } } void outputcheck() { cout << setprecision(4)<<setw(2)<<"**************************************************** "; cout << setprecision(4)<<setw(2)<<"E.C.A. Check#" << i << " Date:"<<date<<endl; cout << setprecision(4)<<setw(2)<<"C++ Advanced Avenue "; cout << setprecision(4)<<setw(2)<<"Rio Rancho, NM 87124 "; cout << setprecision(4)<<setw(2)<<" "; cout <<setw(2)<<"Pay to the order of: " << name <<" "; cout << setprecision(4)<<setw(2)<<"Social Security #: " << ss <<setw(33)<<" "; cout << setprecision(4)<<setw(2)<<" "; cout << setprecision(4)<<setw(2)<<"The amount of:$ " << netpay << setw(33) << " "; cout << setprecision(4)<<setw(2)<<" "<<setw(45) << "Owner "; cout << setprecision(4)<<setw(2)<<" "<<setw(45) <<name<<" "; cout << setprecision(4)<<setw(2)<<"**************************************************** "; outfile << setprecision(4)<<setw(2)<<"**************************************************** "; outfile << setprecision(4)<<setw(2)<<"E.C.A. Check#" << i << " Date:"<<date<<endl; outfile << setprecision(4)<<setw(2)<<"C++ Advanced Avenue "; outfile << setprecision(4)<<setw(2)<<"Rio Rancho, NM 87124 "; outfile << setprecision(4)<<setw(2)<<" "; outfile << setprecision(4)<<setw(2)<<"Pay to the order of: "<< name <<" "; outfile << setprecision(4)<<setw(2)<<"Social Security #: " << ss <<setw(33)<<" "; outfile << setprecision(4)<<setw(2)<<" "; outfile << setprecision(4)<<setw(2)<<"The amount of:$ " << netpay << setw(33) << " "; outfile << setprecision(4)<<setw(2)<<" "<<setw(45) << "Owner "; outfile << setprecision(4)<<setw(2)<<" "<<setw(45) <<name<<" "; outfile << setprecision(4)<<setw(2)<<"**************************************************** "; i=i+1; checkstub(); } void checkstub() { cout<<"Total Hours worked by "<<name<<": "<<hours<<" at "<<wage<<"$ Per Hour "; cout<<"Regular pay:$"<<normpay<<endl; cout<<"Overtime Pay: $"<<otp<<endl; cout<<"----------------------------- "; cout<<"Gross Pay:$"<<grosspay<<endl; cout<<"State Tax:$"<<sdeduc<<" at "<<stax<<endl; cout<<"Fedral Tax: $"<<fdeduc<<" at "<<ftax<<endl; cout<<"Total Deductions: $"<<totaldeduc<<endl; cout<<"Net Pay:"<<setprecision(6)<<"$:"<<netpay<<endl;
outfile<<"Total Hours worked by "<<name<<": "<<hours<<" at "<<wage<<"$ Per Hour "; outfile<<"Regular pay:$"<<normpay<<endl; outfile<<"Overtime Pay: $"<<otp<<endl; outfile<<"----------------------------- "; outfile<<"Gross Pay:$"<<grosspay<<endl; outfile<<"State Tax:$"<<sdeduc<<" at "<<stax<<endl; outfile<<"Fedral Tax: $"<<fdeduc<<" at "<<ftax<<endl; outfile<<"Total Deductions: $"<<totaldeduc<<endl; outfile<<"Net Pay:"<<setprecision(6)<<"$:"<<netpay<<endl;
} void end() { outfile.close(); infile.close(); cout<<"Thank you for using E.C.A. (Electronic Checking Agent) Have a nice day "; exit(0); }
(Edited by EnKRYpTeD at 11:30 am on Aug. 29, 2001)
(Edited by EnKRYpTeD at 11:31 am on Aug. 29, 2001)

New Topic/Question
Reply




MultiQuote



|