### Author Topic: Compute Salary Demo code  (Read 4509 times)

#### louiecerv

• Moderator
• User
• Posts: 85
##### Compute Salary Demo code
« on: November 23, 2005, 02:57:43 AM »
Code for the salary computation
Code: [Select]
`#include <iostream>using namespace std;int main(){    cout << " SAMPLE PROGRAM FOR SALARY " << endl;    int hours, dependents;    float grosspay, netpay;    float socialsec, federal, state, unionfee, health;        cout << "Number of hours worked :  ";    cin >> hours;    cout << "Number of dependents   :  ";    cin >> dependents;        const float HOURLYPAY = 16.75;    if (hours > 40)    {        grosspay = HOURLYPAY * 40 + 1.5 * (hours-40);    } else {        grosspay = HOURLYPAY * hours;    }    socialsec = grosspay * 0.06;    federal = grosspay * 0.14;    state = grosspay * 0.05;    unionfee = 10;        if (dependents >= 3)    {       health = 35;    } else {       health = 0.0;    }        netpay = grosspay -            (socialsec + federal + state + unionfee + health);    cout << "\n\nGrosspay           : " << grosspay << endl;    cout << "- Social Security  : " << socialsec << endl;    cout << "- Federal Tax      : " << federal << endl;    cout << "- State Tax        : " << state << endl;    cout << "- Union dues       : " << unionfee << endl;    cout << "- Health Insurance : " << health << endl;    cout << "---------------------" << endl;    cout << "Net Pay            : " << netpay << endl;               system("PAUSE");    return 0;}`
Analyze. Design. Develop. Debug. Deploy. Maintain.

#### louiecerv

• Moderator
• User
• Posts: 85
##### Errata:
« Reply #1 on: November 23, 2005, 05:23:20 AM »
For IT Students:

I posted this solution after our lecture on Nov 23. I later found out that the text of the problem I typed and showed during the class had some difference with the text of this problem in the book. The union due was erroneously typed as 10% instead of \$10. The health insurance should have been \$35 instead of 35%.

The solution shown here has been corrected and is based on the actual text in the book. Please update your copy.
Analyze. Design. Develop. Debug. Deploy. Maintain.