GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 19-Mar-2010, 20:25
Alviery Alviery is offline
New Member
 
Join Date: Mar 2010
Posts: 2
Alviery is on a distinguished road

Worker's gross and net take-home pay


Hi everyone!

It happens that I am doing a project for a C++ class, but I am having a hard time trying to get the right code. Can anybody tell me what to do?

The program actually has to read in a number of hours a worker work in a week as well the dependants as input. Then will output the worker's gross pay, each withholding amount, and the net take-home pay for the week. It also the program needs to be written so that allows the calculation to be repeated as often as the user wishes. I got this far now.

CPP / C++ / C Code:
#include <iostream>
using namespace std;
int main()
{
	int hours,  dependants,  SocialSecurityTax, FederalIncomeTax, IncomeTax;
	double grosspay, rate;
//input**************************************

cout << "Enter the hourly rate of pay\n$";
cin >> rate;
cout << "Enter the number of hours workeds\n";
cin >> hours;
cout << "Enter the number of dependants\n";
cin >> dependants;

	SocialSecurityTax = 6;
	FederalIncomeTax = 14;
	IncomeTax = 5;

//output************************************
	SocialSecurityTax = rate*40 + 1.5*rate*(hours - 40)/ 6;
	 
//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)- 0;
	

cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
cout << "Hours = " << hours << endl;
cout << "Hourly pay rate = $" << rate << endl;
cout << "Gross pay = $" << grosspay << endl;
cout << "SocialSecurityTax = " << endl;
cout << "IncomeTax = " << endl;
cout << "FederalIncomeTax =  " << endl;
 






	return 0;


}
Last edited by admin : 20-Mar-2010 at 01:03. Reason: Please insert your example C/C++ codes between [CPP] and [/CPP] tags
  #2  
Old 20-Mar-2010, 00:20
Kimmo Kimmo is offline
Regular Member
 
Join Date: Mar 2007
Location: Finland
Posts: 388
Kimmo is a jewel in the roughKimmo is a jewel in the roughKimmo is a jewel in the rough

Re: Help is appreciated!


Quote:
Originally Posted by Alviery
Can anybody tell me what to do?
Implement the rest of the required features. Something like this:

Quote:
The program actually has to read in a number of hours a worker work in a week as well the dependants as input. Then will output the worker's gross pay, each withholding amount, and the net take-home pay for the week. It olso the program needs to be written so that allows the calculation to be repeated as often as the user wishes.


Some thoughts.

CPP / C++ / C Code:
	SocialSecurityTax = 6;
	FederalIncomeTax = 14;
	IncomeTax = 5;
Are these some kind of tax rates as percentages?

CPP / C++ / C Code:
	SocialSecurityTax = rate*40 + 1.5*rate*(hours - 40)/ 6;
Why do you overwrite the tax rate with this? What IS this anyway? Also, I don't claim to know about the taxation system of the country this example represent, but I don't think this calculation is anywhere near correct. I mean, shouldn't calculating the tax somehow take into the account the actual tax percentage? Example run:

Code:
Enter the hourly rate of pay $8 Enter the number of hours workeds 50 Enter the number of dependants 1 SocialSecurityTax: 340 Hours = 50 Hourly pay rate = $8.00 Gross pay = $440.00 SocialSecurityTax = IncomeTax = FederalIncomeTax =
So, I'm earning 440 a week (where did the extra 40 bucks come from? 50 * 8 = 400. Oh, overtime. Where did it say that?) and the social security tax takes 3/4 of my pay? What if I earn less still?

Code:
Enter the hourly rate of pay $5 Enter the number of hours workeds 10 Enter the number of dependants 1 SocialSecurityTax: 162 Hours = 10 Hourly pay rate = $5.00 Gross pay = $-25.00 SocialSecurityTax = IncomeTax = FederalIncomeTax =
I'm being taxed more than I'm even earning? Is that how it really works?

CPP / C++ / C Code:
if (hours > 40)
	grosspay = rate*40 + 1.5*rate*(hours - 40);
else grosspay = rate*hours;
I take it each hour after the 40th is overtime?

How about commenting your code at least a little? I mean, if you're asking for help, one would think you made it as easy as possible for us. But you're doing almost the opposite, hurling rocks on our path at a constant pace. There are no requirements apart from your vague description, you didn't post your code as described in the guidelines, there is no description of the PROBLEM YOU HAVE, there is no description of the possible problems in your code you have already encountered...

It compiles and runs cleanly, though, which is a good start.

If this post wasn't very helpful, which it isn't, then perhaps you should consider if posting your code along with the description of the requirements is really enough to help with the problems you have. This isn't rentacoder.com after all.
 
 

Recent GIDBlogR for statistics by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Any help would be appreciated ELHEK Java Forum 11 28-May-2006 06:13
Noob with a question,any help would be greatly appreciated :) yrostran C Programming Language 7 11-May-2006 02:44
C++ Calculator Problem. Any help much appreciated. SpinDizzy C Programming Language 13 12-Jul-2005 13:35
probably a stupid mistake....lil help appreciated wbsquared03 C++ Forum 9 06-Dec-2004 15:43
Need help with a program if anyone can help it would be appreciated Krc784 C++ Forum 1 03-Nov-2004 20:55

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 19:00.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.