It happens that I am doing a project for my computer class, but it seems not to work. This is the project : An employee is paid at a rate of $16.78 per hour for the first 40 hours worked in a week. Any hours over that are paid at the overtime rate of one and half times that. From the worker's gross pay, 6% is witheld for social security tax, 14% is witheld for federal income tax, 5% is withheld for state income tax, and $10 per week is withheld for un ion dues. If the worker has three or more dependents, then an additional $35 is withheld to cover the extra cost of health insurance beyond what the employer pays. So the homework is to write a program that reads in the number of hours worked ina week and the number of dependents an input, and will then output the worker's gross pay, each withholding amount and the net take-home pay for the week. Can anybody tell me what I am doing wrong? This is actually the code.

#include <iostream>
using namespace std;
int main()
{
	int hours, dependants;
 	double grosspay, rate, netpay, unionduecharge, SocialSecurityTax, FederalIncomeTax, IncomeTax ;
//input*************************************
cout << "Enter the number of hours workeds\n";
cin >> hours;
cout << "Enter the number of dependants\n";
cin >> dependants;
rate = 16.78;

SocialSecurityTax = .06;
	FederalIncomeTax = .14;
	IncomeTax = .05;
	unionduecharge = 10;
	

	 
//process*************************************
if (hours > 40)
	grosspay = rate*40 + 1.5*rate*(hours - 40);
else grosspay = rate*hours;
	

if (dependants >= 3)
	grosspay =rate*40 + 1.5*rate*(hours - 40)- 35;
else grosspay = rate*40 + 1.5*rate*(hours - 40);

//******************output*******************************

SocialSecurityTax == rate*40 + 1.5*rate*(hours - 40) - .06*(rate*40 + 1.5*rate*(hours - 40));




cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
cout << "Hours = " << hours << endl;

cout << "Gross pay = $" << grosspay << endl;
cout << "SocialSecurityTax = " <<  endl;
cout << "IncomeTax = " << endl;
cout << "FederalIncomeTax =  " << endl;
cout << "netpay = " <<endl; 
cout << "unionduecharge =" <<endl;





	return 0;


}

Edited 6 Years Ago by WaltP: Added CODE Tags

What problem are you facing with the code? I can some of them.

1) You don't have to calculate the gross pay for everything. Calculating it in the beginning is enough.

2)SocialSecurityTax == rate*40 + 1.5*rate*(hours - 40) - .06*(rate*40 + 1.5*rate*(hours - 40));

There should be only one "=" sign.
SocialSecurityTax = 06*(grosspay); ---- Social security tax is 6% of the grosspay.

This article has been dead for over six months. Start a new discussion instead.