All pastes #190571 Raw Edit

Anonymous

public cpp v1 · immutable
·published 2006-10-04 03:23 UTC
rendered paste body
//P03 Pay with Validation - ******  #include <iostream>using namespace std;//Listed here are the function prototypes        double inputRate();    int    inputHours();    double calcGross(double rate, int hours);    double calcTax(double gross, double taxRate);//Listed here are the constant global variables in all capital letters.const double OVERTIME_RATE = 1.5;void main(){//Listed here are the local cosntant variables in all capital letters    const double    UNION_DUES   = 10.00,        FICA_RATE  = 0.06,		FEDERAL_RATE = 0.15,   STATE_RATE = 0.05;//These are the defined variables. All in lower case.	       int hours;           double rate, total, fica, federal, state, netpay, netHourly;//This formaul sets the decimal place to 2.	cout.setf(ios::fixed);    cout.setf(ios::showpoint);    cout.precision(2);//This will display the author of this programs name//at the top of the program.	cout << "P03 - *******\n\n\n";//This is a do while loop, which means that the conidtion at the end//of the loop. The statements in this loop are executed at least once.    	do    {        cout << "Enter a value between $10 and $15.00 for the hourly rate:";        cin >> rate;//Set the maximum and minimum value of the rate here.    } while (rate < 10 || rate > 15);    cout << endl;		 //This is a user input value for hours.    hours = 0;//Set the maximum and minimum value of the hours here.    while (hours < 1 || hours > 50)    {        cout << "Enter a value between 1 and 50 for the \n"			 << "Number of hours worked: ";        cin >> hours;    }//This formula tells the program that if the number of hours worked//is greater than 40, then the overtime rate comes into affect.	     if (hours > 40)        total   = (40 * rate) + ((hours - 40) * rate * OVERTIME_RATE);     else        total   = hours * rate;     fica       = total * FICA_RATE;     federal    = total * FEDERAL_RATE;             state      = total * STATE_RATE;     netpay     = total - (fica + federal + state + UNION_DUES);     netHourly  = netpay / hours;//Here is where the results are displayed and echoed back to//the user.//Display the values stored in constanets.//Use the space bar between : and \t in labels instead of//the tab key for accurate alignment.    cout << endl         << "Hourly Rate: \t" << rate  << endl         << "Hours Worked:\t" << hours << endl         << "Total Pay:   \t" << total << endl         << "FICA Tax:    \t" << fica    << " at " << FICA_RATE << endl         << "Federal Tax: \t" << federal << " at " << FEDERAL_RATE << endl         << "State Tax:   \t" << state   << " at " << STATE_RATE << endl         << "Union Dues:  \t" << UNION_DUES  << endl         << "Net Pay:     \t" << netpay     << endl         << "Net Hourly:  \t" << netHourly  << endl;    cout << "\nThank you!\n\n";}//end of main