Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- project5.cpp
- Andre Fecteau
- CSC135-101
- December 1, 2013
- This program will take in the name of the file and then process the information inside of the file
- */
- #include <iostream>
- #include <string>
- #include <iomanip>
- #include <fstream>
- #include <cstdlib>
- using namespace std;
- /*
- // Declarations
- // Initalizations
- // Input
- // Process
- // Output
- // Prolouge
- */
- void instruct(){
- cout <<"| ------------------------------------------------------------------------- |" << endl;
- cout <<"| ------ Welcome to the employee pay and tax calculator ------------------- |" << endl;
- cout <<"| ------------------------------------------------------------------------- |" << endl;
- cout <<"This program will take the input of your filename that contains the:" << endl;
- cout <<"Employee Name, then rate, then hours worked for Mon. to Friday on seperate" << endl;
- cout <<"Lines respectively. Then do the math for the Net pay. Out this information" << endl;
- cout <<"It will then do this until there is no more data left then quit." << endl;
- cout << endl;
- }
- double name_hourly(ifstream &in){
- string their_name = " ";
- double hourly = 0.0;
- getline (in, their_name);
- in >> hourly;
- return 0;
- }
- double hours_totaled(ifstream &in){
- double monday = 0.0;
- double tuesday = 0.0;
- double wednesday = 0.0;
- double thursday = 0.0;
- double friday = 0.0;
- double total = 0.0;
- in >> monday;
- in >> tuesday;
- in >> wednesday;
- in >> thursday;
- in >> friday;
- total = monday + tuesday + wednesday + thursday + friday;
- return total;
- }
- double doWork(double hours, double &hourly){
- double pay_amount_gross = 0.0;
- double pay_amount_net = 0.0;
- double kept_precentage = 0.0;
- double pay_kept = 0.0;
- pay_amount_gross = hours*hourly;
- if(pay_amount_gross < 500){kept_precentage = 23.7;}
- if(pay_amount_net >= 500){kept_precentage = 33.9;}
- pay_kept = kept_precentage / pay_amount_gross * 100;
- pay_amount_net = pay_amount_gross - pay_kept;
- return 0;
- }
- void outInfo(double &pay_amount_gross, string &their_name, double &hourly, double hours, double &pay_amount_net, double &pay_kept){
- cout <<"| ------------------------------------------------------------------------- |" << endl;
- cout <<"| ----------------------- Calculation Totals ------------------------------ |" << endl;
- cout <<"| ------------------------------------------------------------------------- |" << endl;
- cout <<" Employee Name: " << their_name << endl;
- cout <<" Gross Pay: $" << setprecision(2)<< fixed << pay_amount_gross << endl;
- cout <<" Amount Kept: $"<< setprecision(2)<< fixed << pay_kept << endl;
- cout <<" Net Pay: $"<< setprecision(2)<< fixed << pay_amount_net << endl;
- }
- string file(double &pay_amount_gross, string &their_name, double &hourly, double hours, double &pay_amount_net, double &pay_kept){
- ifstream in;
- while (true)
- {
- string infilename;
- cout << "Please Enter the name of the file to be opened: ";
- getline( cin, infilename);
- in.open( infilename.c_str() );
- if(in)break;
- }
- if(in)
- {
- while(!in.eof())
- {
- name_hourly(in);
- hours_totaled(in);
- doWork(hours, hourly);
- outInfo(pay_amount_gross, their_name, hourly, hours, pay_amount_net, pay_kept);
- }
- }
- return 0;
- }
- int main(){
- double pay_amount_gross;
- string their_name;
- double hourly;
- double hours;
- double pay_amount_net;
- double pay_kept;
- instruct();
- file(pay_amount_gross, their_name, hourly, hours, pay_amount_net, pay_kept);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement