Help

Write your question here.ok so i did a program that will take the number of hours worked in a week annd the number of dependents ans inputs and then outputs the workers gross pay, each withholding amount, and the net take home pay per week.



The Program should come out as this:
Regular Hours :34
Overtime hours: 0
gross pay : $323.00
social tax: 19.38
federal tax: $45.22
Statte tax: $16.15
Number of dependents covered: 2
additional health insurance expence: $0

Net take home pay: $236.25


The employer pay rate is 9.50
the employer worked 34 hours "regular hours 40 or less"
if any hours are paid at over time rate of one and one half time that
from the gross pay, 6% of social is with held, 14% form federal income, 5% from state income, 6$ per week from union dues, and if worker has 3 or more covered dependent, then an additional 10$ is wothheld to cover the extra cost of health insurance

the program runs but theres still errors in it, it did not make some of the calculations right.

what formula do i use to calculate overtime hours if there was over time?
what formula do i use to take out union dues from total income?
How to I set the number of independents covered to match the health cost if it was 3 or more?


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
  #include <iostream>
 using namespace std;
 
int main ()
 {
 int regHours; // Regular Hours
 float hourlyPay, gross, otime, socialtax, federaltax, statetax, uniondues, dep, health; // gross income, overtime, social tax, federal tax, state tax, union dues, depen covered, health insurance 
double opay, sopay, fpay, spay, unpay, deppay, healthpay, netpay; // overtime scoial federal state union dependents and health withholdings including netpay 

// Loop to do everything
 {
 cout << "Hello Employee" << endl;

 cout << "Enter hours you have worked: ";
 cin >> regHours; 

cout << "Enter hourly pay rate: $";
 cin >> hourlyPay;

 cout << "Enter overtime rate: " ;
 cin >> otime;
 
cout << "Enter percentage to be withheld for social security tax in decimal form: ";
 cin >> socialtax;
 
cout << "Enter percentage to be withheld for federal income tax in decimal form: ";
 cin >> federaltax;
 
cout << "Enter percentage to be withheld for state income tax in decimal form: ";
 cin >> statetax;

 cout << "Enter Union dues: ";
 cin >> uniondues;

 cout << "Enter number of dependents covered: ";
 cin >> dep;

 cout << "Enter additional health insurance expence: ";
 cin >> health;


 gross = regHours * hourlyPay; //Grosspay
 {
 gross += (regHours - 40) * otime * hourlyPay;
 }
 opay = regHours * 1.5; //Over time hours
 sopay = gross * socialtax; //Social income tax withholdings
 fpay = gross * federaltax; //Federal income tax withholdings
 spay = gross * statetax; //State withholdings
 unpay = gross - uniondues; //Union Dues
 deppay = gross - healthpay; //Number of dependents covered
 healthpay = gross - health; //Addition health insurance expence
 if( deppay >= 3 )
 {
 healthpay = gross - 10;
 }
 netpay = gross - opay - sopay - fpay - spay - deppay - healthpay; //Netpay

 cout << "Weekly Report: \n\n";
 cout << "Regular Hours: " << regHours << endl;
 cout << "Gross Pay: $" << gross << endl;
 cout << "Social income tax: $" << sopay << endl;
 cout << "Federal income tax: $" << fpay << endl;
 cout << "Union dues: $" << unpay << endl;
 cout << "Number of dependents covered: $" << deppay << endl;
 cout << "Additional health insurace expence: $" << healthpay << endl;
 cout << "Net take home pay: $" << netpay << endl;

 }

 system("pause");
 return 0;

 }
I think that this is more in the advanced departement

#include <windows.h> also
On a quick look, you have a lot of redundancy and things out of order. Social Security, federal and state tax, union dues, and additional heath costs are always the same as far as I can tell so there is no reason to ask what they are. Overtime rate is based on pay rate so once again there is no reason to ask. All the user should have to answer is hours worked, pay rate (assuming that is not also a fixed amount), and number of dependents.

what formula do i use to calculate overtime hours if there was over time?

if(hrsWorked > 40) then
grossPay = ((hrsWorked - 40) * overPay) + (40 * regPay)

what formula do i use to take out union dues from total income?

netPay = grossPay - dues // assumes no other deductions

How to I set the number of independents covered to match the health cost if it was 3 or more?

if(dependents > 2) then
netPay = grossPay - 10 // assumes no other deductions

@jasonwynn10, This not advanced, it is very basic and there is no reason to include widows.h
in what lines do i enter those?
what lines do I enter those?
42
43
44
45
gross = regHours * hourlyPay; //Grosspay
 {
 gross += (regHours - 40) * otime * hourlyPay;
 }
should be gross = hours * hourlyPay + (hours - 40) * hourlyPay / 2.0; or something similar. I suppose in your case it would be gross = (regHours + otime) * hourlyPay + otime * hourlyPay / 2.0;
Last edited on
can you run it and see if theres any other errors?
im trying to get rid of all the miscalculations @giblit @admkrk
Topic archived. No new replies allowed.