I am new at programming and got an assignment that is due tomorrow. I have to develop a program that calculates pay and bonus for three sets of workers. HELP!!!

Recommended Answers

All 20 Replies

What do you have so far?

The Member Rules state "Do not post threads with generic subjects such as "HELP ME" or "PROBLEM". Instead, clearly state a phrase describing the problem as the thread's title." Please post proper titles next time.
Also, we aren't psychic. How can we possibly figure out what help you need with given the information you provided. Please read the required posts and rules.

What do you have so far?

I have the information that is to go in the programme i have tried writing it but so far i keep getting two errors what am i doing wrong?
The assignment goes:
Voila Wireless Limited (VWL) is a newly established wireless services provider, with branches in Kingston, Mandeville and Montego Bay. The Company is in need of a computer programme to calculate the salaries for its monthly paid full time employees. The programme should receive an employee’s gross monthly salary (GMS) as input, and then return the Net Pay after deducting various taxes and charges. The deductions a summarised in the table below:
DEDUCTIONS
CALCULATIONS
National Insurance (NIS)
$520 or $1040
National Housing Trust (NHT)
2% of Monthly Gross
Tax Free Amount (TFA)
$10,000
Pension Contributions (PEN)
5% of Monthly Gross
Education Tax (EDTX)
2% of (GMS - NIS - PEN)
Income Tax (INTX)
25% of (GMS – PEN – NIS -TFA)
Surely, an employee’s Net Pay, is the removal of these deductions from the gross monthly salary, i.e. NET PAY = GMS – (INTAX + EDTX + PEN + NIS + NHT). The user must be prompted to enter the identification number (ID#) of the employee and the GMS only; the programme should return the results and then prompt the user for a new entry of another GMS and Employee ID#. You may assume that ID numbers range between 3000 and 9000. The top executives of the company, which are identified by ID numbers greater than or equal to 8000, are given a $15,000.00 bonus, while middle management personnel (ID# 7000 – 7999) gets $9,000.00; all other staff members (ID# 3000 – 6999) receive a bonus of $3000.00. Further employees who receive a GMS of over $60,000.00 will be required to pay $1040 for NIS and $520 otherwise. Generally, only persons earning more than the TFA should be obliged to pay the various deductions

Ok. What does your code look like, that's the assignment.

Ok. What does your code look like, that's the assignment.

What i have so far is this:

//#include<iostream.h>
#include<stdio.h>
int GMS,NIS,NHT,PEN,TFA,EDTX,INTX,Bonus1,Bonus2,Bonus3

double TFA=$10,000
NIS=$520 OR $1040
NHT=2% OF MONTHLY GROSS
PEN=5% OF MONTHLY GROSS
EDTX=2% OF (GMS-NIS-PEN)
INTX=25% OF (GMS-PEN-NIS-TFA)
Bonus1=$15000
Bonus2=$9000
Bonus3=$3000

int main()
{
	int IdNum
double GMS,NIS,NHT,PEN,EDTX,TFA,INTX,Bonus1,Bonus2,Bonus3;
double TFA=$10000;
cout<<"\n Enter IdNum";
cin>>IdNum;

if(IdNum>=9000)

netPay=GMS-(NIS+NHT+PEN+EDTX+INTX)+Bonus1+TFA
if(IdNum7000-7999)

netPay=GMS-(NIS+NHT+PEN+EDTX+INTX)+Bonus2+TFA;

else
netPay=GMS+Bonus3
if (GMS>=$60000)
NIS=$1040;
else
NIS=$520
if (GMS=TFA=$10000)
NIS,NHT,EDTX,PEN,INTX:=0

return 0;
//}

if(IdNum7000-7999) can be expressed as if(IdNum >=7000 && IdNum <=7999) but should probably be an else if as it stands it will only pair with the else below it. Also, if you have multiple statements on else you need {} around the group of statements.

Also, please enclose your code in code tags. Edit your post and type:

[code]

//code goes here //in it's entirety

[/code]

if(IdNum7000-7999) can be expressed as if(IdNum >=7000 && IdNum <=7999) but should probably be an else if as it stands it will only pair with the else below it. Also, if you have multiple statements on else you need {} around the group of statements.

Also, please enclose your code in code tags. Edit your post and type:

[code]

//code goes here //in it's entirety

[/code]

I have done that. Is that the correct way to do it

This syntax is incorrect: NIS,NHT,EDTX,PEN,INTX:=0 They can all be set equal to each other and the final one to zero, e.g., NIS = NHT =EDTX = 0; .

Get rid of lines 3-13 in your code. Try to only declare your variables in main.

Your values are not being magically calculated from your statements in plain English up at the top, these values need to be calculated explicitly.

I did not check your code against your specifications so you should probably do one or two calculations on a calculator and see if they match what you got in the program.

This syntax is incorrect: NIS,NHT,EDTX,PEN,INTX:=0 They can all be set equal to each other and the final one to zero, e.g., NIS = NHT =EDTX = 0; .

Get rid of lines 3-13 in your code. Try to only declare your variables in main.

Your values are not being magically calculated from your statements in plain English up at the top, these values need to be calculated explicitly.

I did not check your code against your specifications so you should probably do one or two calculations on a calculator and see if they match what you got in the program.

I have tried getting rid of the lines and declaring them in main but I am now getting fifty errors.

Post what you have now and the first 5-10 errors.

Post what you have now and the first 5-10 errors.

/#include<iostream.h>
#include<stdio.h>


int main()

{
	int GMS,NIS,NHT,PEN,TFA,EDTX,INTX,Bonus1,Bonus2,Bonus3

TFA=$10,000
NIS=$520 OR $1040
NHT=2% OF MONTHLY GROSS
PEN=5% OF MONTHLY GROSS
EDTX=2% OF (GMS-NIS-PEN)
INTX=25% OF (GMS-PEN-NIS-TFA)
Bonus1=$15000
Bonus2=$9000
Bonus3=$3000

	int IdNum
double GMS,NIS,NHT,PEN,EDTX,TFA,INTX,Bonus1,Bonus2,Bonus3;
double TFA=$10000;
cout<<"\n Enter IdNum";
cin>>IdNum;

if(IdNum>=9000)

netPay=GMS-(NIS+NHT+PEN+EDTX+INTX)+Bonus1+TFA
else if{IdNum>=7000 && <=7999}

netPay=GMS-(NIS+NHT+PEN+EDTX+INTX)+Bonus2+TFA;

else
{netPay=GMS_Bonus3}
if (GMS>=$60000)
NIS=$1040;
else
{NIS=$540}
if (GMS=TFA=$10000)
NIS=NHT=EDTX=PEN=INTX=0;

return 0;
}//

C:\Users\babyd\Desktop\C++ WORK SPACE\Assignment1.cpp(12) : error C2146: syntax error : missing ';' before identifier 'TFA'
C:\Users\babyd\Desktop\C++ WORK SPACE\Assignment1.cpp(12) : error C2065: '$10' : undeclared identifier
C:\Users\babyd\Desktop\C++ WORK SPACE\Assignment1.cpp(13) : error C2146: syntax error : missing ';' before identifier 'NIS'
C:\Users\babyd\Desktop\C++ WORK SPACE\Assignment1.cpp(13) : error C2065: '$520' : undeclared identifier
C:\Users\babyd\Desktop\C++ WORK SPACE\Assignment1.cpp(13) : error C2146: syntax error : missing ';' before identifier 'OR'

I mean seriously! Could you quote the passages in your book that states these are valic C++ statements:

TFA=$10,000
NIS=$520 OR $1040
NHT=2% OF MONTHLY GROSS
PEN=5% OF MONTHLY GROSS
EDTX=2% OF (GMS-NIS-PEN)
INTX=25% OF (GMS-PEN-NIS-TFA)
Bonus1=$15000
Bonus2=$9000
Bonus3=$3000
int GMS,NIS,NHT,PEN,TFA,EDTX,INTX,Bonus1,Bonus2,Bonus3

TFA=$10,000
NIS=$520 OR $1040
NHT=2% OF MONTHLY GROSS
PEN=5% OF MONTHLY GROSS
EDTX=2% OF (GMS-NIS-PEN)
INTX=25% OF (GMS-PEN-NIS-TFA)
Bonus1=$15000
Bonus2=$9000
Bonus3=$3000

You understand that with the exception of the first line there (and that's missing a semicolon at the end and the type is wrong and you declare variables with the same name later, etc.) all the rest of this is not "legal" code. You do not need the dollar signs and you need to express those formulas in the code when those variables have something meaningful in them.

So by the time you hit something like line 28 all those variables must be accounted for or your answer will be garbage.

The first few steps I took were as follows:
Take in the ID
Take in the GMS
Is the GMS greater than the tax free amount
if so, proceed to calculate the NIS
calculate all the rest of the values
Else
Assign zero to the values of the taxes

Add the bonus
Output the net

I mean seriously! Could you quote the passages in your book that states these are valic C++ statements:

TFA=$10,000
NIS=$520 OR $1040
NHT=2% OF MONTHLY GROSS
PEN=5% OF MONTHLY GROSS
EDTX=2% OF (GMS-NIS-PEN)
INTX=25% OF (GMS-PEN-NIS-TFA)
Bonus1=$15000
Bonus2=$9000
Bonus3=$3000

I am not using a book. That is how my tutor said i was to set it out.Is there another way?

See my post above, but (at the appropriate time when you have the values intact) you need to write something like PEN = 0.05 * GMS; . I think you misunderstood what he or she was trying to tell you. It never hurts to have a reference book with which to follow along.

What does this syntax error mean: syntax error : missing ';' before '='

It means you have stated something incorrectly to the compiler (the "words" are potentially correct but the "sentence" is jumbled around). Paste in the code on the line before the error, the line of the error, and the line after.

It means you have stated something incorrectly to the compiler (the "words" are potentially correct but the "sentence" is jumbled around). Paste in the code on the line before the error, the line of the error, and the line after.

#include<iostream.h>
#include<stdio.h>

int main()

{
int GMS,NIS,NHT,PEN,TFA,EDTX,INTX,Bonus1,Bonus2,Bonus3;

TFA=10,000;
NIS:=520
NIS:=1040
NHT:=0.02*GMS
PEN:=0.05*GMS
EDTX:=0.02*GMS-(NIS+PEN)
INTX:=0.25*GMS-(PEN+NIS+TFA)
Bonus1:=15000
Bonus2:=9000
Bonus3:=3000

cout<<"\n Enter IdNum";
cin>>IdNum;
cout<<"\n Enter GMS";
cin>>GMS;
if(IdNum>=9000)

NetPay=GMS-(NIS+NHT+PEN+EDTX+INTX)+Bonus1+TFA;
if
(IdNum>=7000<=7999)
NetPay=GMS-(NIS+NHT+PEN+EDTX+INTX)+Bonus2+TFA;
else(NetPay=GMS+Bonus3);
if(GMS>=60000)
NIS=1040;
else(NIS=520);
if(GMS=TFA=10000)
NIS=NHT=EDTX=PEN=INTX=0;
else

return 0;
}//

This is what i have now and i am only getting three errors. here they are: error C2143: syntax error : missing ';' before '='
error C2065: 'IdNum' : undeclared identifier
'NetPay' : undeclared identifier
What exactly am I to do?

As Jonsca said, TFA=$10,000 is not a valid statement. It needs to be TFA=10000 since $ and , are not valid digits.

And the computer has no idea what NHT=2% OF MONTHLY GROSS means. You need to calculate the value of monthly gross in some variable (maybe MonthlyGross ) then set NHT to 2% of it: NHT = MonthlyGross * 0.02; 2% is meaningless also, by the way. It's 0.02.

int main()

{
//Wrong, these should be doubles you had it right before
int GMS,NIS,NHT,PEN,TFA,EDTX,INTX,Bonus1,Bonus2,Bonus3;

TFA=10,000;  //OK, this makes sense, you have an established variable and you are assigning the value to it (though no commas!))
NIS:=520  //meaningless  no such symbol := 
NIS:=1040 //meaningless
NHT:=0.02*GMS //X What is GMS at this point? nothing.
PEN:=0.05*GMS //X
EDTX:=0.02*GMS-(NIS+PEN) //  X
INTX:=0.25*GMS-(PEN+NIS+TFA) //X
Bonus1:=15000 //X
Bonus2:=9000 //X
Bonus3:=3000 //X
All of those with the Xs are wrong too for the same reasons
cout<<"\n Enter IdNum";
cin>>IdNum;  //you don't have a declaration for IdNum earlier.  Since this is C++ you could declare it (i.e., int IdNum;) right before this but put it at the top to keep track
cout<<"\n Enter GMS";
cin>>GMS;
if(IdNum>=9000)
//These calculations are all the same, do them first and then add on the bonuses for these employees last, they don't depend on any of the other values but GMS
NetPay=GMS-(NIS+NHT+PEN+EDTX+INTX)+Bonus1+TFA;
  //don't add the TFA back on, that's just the amount free from taxes
if(IdNum>=7000<=7999)   ****
//go back and look at how I had shown you before, it doesn't look like this and you need else if for this step
NetPay=GMS-(NIS+NHT+PEN+EDTX+INTX)+Bonus2+TFA;
else(NetPay=GMS+Bonus3);
if(GMS>=60000)
NIS=1040;  //too late you already calculated the NET just above this
else(NIS=520); //nope should be in braces or nothing else has no conditions
if(GMS=TFA=10000)
NIS=NHT=EDTX=PEN=INTX=0; //got the right idea with this, or you can initialize them to zero at the top and leave them that way if it is less than the TFA
else

return 0;
}//

So read in the variables, then do the intermediate calculations, then do the net calculation. Think of how you would do this on paper, what would you need when. In fact, do one run on paper so you can see what you need to do the problem.
At this stage all you can do it tell the computer to stop and points and evaluate conditions. Therefore if a computer hasn't calculated a value yet it can't use that value in subsequent calculations.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.