Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- project4.cpp
- Andre Fecteau
- CSC135-101
- November 14, 2013
- This program takes in an employee name, hourly rate, and amount of hours worked. It then outputs the amount of taxes taken out.
- */
- #include <iostream>
- #include <string>
- using namespace std;
- /*
- Basic Function for Copy Paste
- <function type> <function name> (){
- // Declarations
- // Initalizations
- // Input
- // Process
- // Output
- // Prolouge
- }
- */
- void displayInfo(){
- // Declarations
- // Initalizations
- // Input
- // Process
- // Output
- cout <<"| ------------------------------------------------------------------------- |" << endl;
- cout <<"| ------ Welcome to the employee pay and tax calculator ------------------- |" << endl;
- cout <<"| ------------------------------------------------------------------------- |" << endl;
- cout <<"| This program will take in the employees name |" << endl;
- cout <<"| Take in their hourly rate |" << endl;
- cout <<"| Take in the hours worked |" << endl;
- cout <<"| Then calculate tax and total earnings post tax and output the information |" << endl;
- cout <<"| ------------------------------------------------------------------------- |" << endl;
- cout << endl;
- // Prolouge
- }
- string employeeName(){
- // Declarations
- string name;
- // Initalizations
- name = ' ';
- // Input
- cout << "Please enter employee name (First and last with space is accepted): ";
- getline (cin, name);
- cout << endl;
- // Process
- // Output
- // Prolouge
- return name;
- }
- float hourlyRate(){
- // Declarations
- float rate;
- // Initalizations
- rate = 0;
- // Input
- // Process
- cout << "Please enter the hourly rate for the employee: ";
- cin >> rate;
- // Output
- // Prolouge
- return rate;
- }
- float hoursWorked(){
- // Declarations
- float hours;
- float temp;
- float running;
- // Initalizations
- hours = 0;
- running = 0;
- temp = 0;
- // Input
- for(int counted = 1; counted < 6; counted++)
- {
- cout << "Please enter the amount of hours worked on day " << counted << ": ";
- cin >> hours;
- running = hours + temp;
- temp = running;
- cout << endl;
- }
- return temp;
- }
- float doCalculations(float hourlyRate, float hoursWorked){
- // Declarations
- float gross;
- float precentage;
- float withholdingAmount;
- float net;
- // Initalizations
- gross = 0;
- precentage = 0;
- withholdingAmount = 0;
- net = 0;
- // Input
- // Process
- gross = hourlyRate * hoursWorked;
- if(gross < 500){precentage = 23.7;}
- if(gross >= 500){precentage = 33.9;}
- withholdingAmount = precentage / gross * 100;
- net = gross - withholdingAmount;
- // Output
- // Prolouge
- return net;
- }
- void outputInfo(float doCalculations, float hoursWorked, float hourlyRate, string employeeName){
- // Declarations
- float outGross;
- float outWithHeld;
- // Initalizations
- outGross = 0.0;
- outWithHeld = 0.0;
- // Input
- // Process
- outGross = hoursWorked * hourlyRate;
- outWithHeld = outGross - doCalculations;
- // Output
- cout <<"| ------------------------------------------------------------------------- |" << endl;
- cout <<"| ----------------------- Calculation Totals ------------------------------ |" << endl;
- cout <<"| ------------------------------------------------------------------------- |" << endl;
- cout << " Employee Name: "<< employeeName << endl;
- cout << " Gross Pay: "<< outGross << endl;
- cout << "Total Witholding Amount: "<< outWithHeld <<endl;
- cout << " Net Pay: "<< doCalculations << endl;
- cout <<"| ------------------------------------------------------------------------- |" << endl;
- cout <<"| ------------------------------------------------------------------------- |" << endl;
- // Prolouge
- }
- int main(){
- // Declarations
- string done;
- string nameOf;
- float hourRate;
- float worked;
- float calcs;
- // Initalizations
- done = "done";
- nameOf = " ";
- hourRate = 0;
- worked = 0;
- calcs = 0;
- // Input
- displayInfo();
- while( nameOf != done)
- {
- nameOf = employeeName();
- if(nameOf == done){break;}
- hourRate = hourlyRate();
- worked = hoursWorked();
- calcs = doCalculations(hourRate, worked);
- outputInfo(calcs, hourRate, worked, nameOf);
- cin.ignore();
- }
- cout << "was done";
- // Process
- // Output
- // Prolouge
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement