# HELP! New To C++ and stuck

• 06-30-2003
flatline911
HELP! New To C++ and stuck
Hello,

I am new to c++ this year, i know this looks like nothing hard to you but i am stuck. Should i use bool or if and else? I have been working on this for a while it has me baffled.

Thanks for your time,
John

[tag]

Write a 'C++' program to calculate an employee's net pay based on the information given below. Save your program with the name: BUDGET.CPP

INPUT
The following information will be entered from the keyboard for each employee:

Employee's name

Base Pay

Dollar amount of sales earned this month

PROCESSING
Calculations are to be done as follows:

Commission = Total Sales less \$200 * 6.5% (if Total Sales are less than \$1,200.00)

Commission = Total Sales less \$150 * 7.25% (if Total Sales are \$1,200.00 or more)

Gross Pay = Base Pay + Commission

Deductions:

Health Insurance = \$58 (if Gross Pay is \$600 or more)

Retirement Account = 9% of Base Pay and 17% of Commission

Taxes = 24.5% of Gross Pay

Net Pay = Gross Pay – Deductions

OUTPUT
Output will be to the screen. Print title and headings as indicated below. Print the base pay, amount of sales, amount of commission, gross pay, all deductions, and net pay. Where nnn appears, you calculated answers should be displayed. Wherever nnn.nn appears, your answer should display two digits to the right of the decimal point. Note that all the values must be aligned vertically. Remember your program should work for any employee.

Pseudocode for the assignment:

1 Input the Employee's name, Base Pay, and Dollar amount of sales earned this month.

2 Check the total sales for less than 1200

a. if yes compute commission = Total Sales less \$200 * 6.5%

b. if no compute commission = Total Sales less \$150 * 7.25%

3 Compute Gross Pay

4 Figure Deductions

a. check Gross Pay for under 600

1. if yes Health Insurance = 0

2. if no Health Insurance = 58

b. Figure Retirement Account = 9% of Base Pay and 17% of Commission

c. Figure Taxes = 24.5% of Gross Pay

5 Figure Net Pay = = Gross Pay – Deductions

6 Print Name of Employee Header to the screen

7 Print employee information to the screen.

Output Format:

BUDGET REPORT FOR name of employee

INCOME:

Base Pay: nnn.nn

Sales: nnnn.nn

Commission: nnn.nn

Gross: nnnn.nn

Deductions:

Insurance nnnn.nn

Retirement nnnn.nn

Taxes nnnn.nn

Net: nnnn.nn

[/tag]

:confused: :confused:
• 06-30-2003
flatline911
This is what I have so far I thought i almost had it.

Thanks alot

Code:

#include <iostream.h>
#include <iomanip.h>

//Named constants - residential customers
const double healthi = 58.00;
const double h0 = 0.00;

int main()
{
//Variable declaration
char empn[25];
double  basepay;
int  stm;
int comm1 ;
int comm2;
int comm3 ;
int comm4;
double gp;
double rt1;
double rt2;
double rt3;
double test;
double test1;
double ngp;
double ngp1;
double ngp2;
double ngp3;
double ngp0;
//Inputs - Emp. Name, Base Pay and Sales This Month

cout<<fixed<<showpoint;
cout<<setprecision(2);

cout<<endl;
cout<<"Enter Employee's name: ";
cin>> empn;
cout<<endl;

cout<<"Enter Base Pay:";
cin>> basepay;
cout<<endl;

cout<<"Enter Dollar Amount Of Sales This Month: ";
cin>> stm;
cout<<endl;

//Commission Processiong

if (stm < 1200)

{
comm1=stm-200;
comm2=comm1*.065;
cout<<endl;

gp=comm2+basepay ;
cout<<"\nGross Pay: "<<gp ;
}
else
{ comm3=stm-150;
comm4=comm3*.0725;

cout<<endl;

gp=comm4+basepay ;
cout<<endl; }
cout<<endl;

//Deductions

cout<<endl;
if (gp < 600)

{
h0;

cout<<endl;

}
else

{
cout<<endl;
healthi ;
}

cout<<endl;
rt1=basepay*.09;

if (comm2 > comm4)
{rt2=comm2*.17 ;
test=gp-rt2 ;
}
else
{
rt3=comm4*.17;
test1=gp-rt3 ;

}
;

ngp=gp-(healthi || h0);
ngp1=ngp-rt1;
ngp0=ngp1-(rt2 || rt3);
ngp2=ngp0*.245;
ngp3=ngp0-ngp2;

cout<<endl;

if (test > test1)
{cout<<"\n                    BUDGET REPORT FOR"<<empn ;
cout<<"\nINCOME:" ;
cout<<"\nBase Pay:\$"<<basepay ;
cout<<"\nSales:\$"<<stm ;
cout<<"\nCommission:\$"<<comm2 || comm4 ;
cout<<"\nGross:\$"<<gp ;
cout<<"\nDeductions:" ;
cout<<"\n    Insurance: -\$"<<(h0 || healthi) ;
cout<<"\n    Retirement:-\$"<<rt1 ;
cout<<"\n    Taxes:    -\$"<<ngp2 ;
cout<<"\n******************************************************************";
cout<<"\nNet:\$"<<ngp3 ;
}

return 0;
}

:)
• 06-30-2003
flatline911
I could not figure out how to get it to all come together at the end. thats why you see the ( heathi || h0 ) :mad: I was getting frustrated and trying anything lol. At the end i could not get it to total it all up with the retirement and take out the health insurance and all the other forks in the road. I got so frustrated i could not think straight,lol. what kind of code can include all those processes? Thats why i have so many ngp=new gross pay i had a ngp every time i took out a deduction. I felt like i was coming at this the wrong way.

Thanks alot
• 06-30-2003
flatline911
Help please how can i deduct the retirement plan from the gross which is based on the commission and manage to come out with my net?:(
• 07-01-2003
flatline911
Salem,

Thanks a ton for your help, I finally saw the light with your help. I think I was over analyseing the problem and not letting the program think a little. I have posted my final code below, tell me what you think.

Again thanks for the help,
John

Code:

#include <iostream.h>
#include <iomanip.h>

//Named constants - residential customers
const double healthi = -58.00;
const double h0 = 0.00;

int main()
{
//Variable declaration
char empn[25];
double  basepay;
int  stm;
int commission ;
double gross_pay;
double heath_contribution;
double retirement;
double Net;
double taxes;
//Inputs - Emp. Name, Base Pay and Sales This Month

cout<<fixed<<showpoint;
cout<<setprecision(2);

cout<<endl;
cout<<"Enter Employee's name: ";
cin>> empn;
cout<<endl;

cout<<"Enter Base Pay:";
cin>> basepay;
cout<<endl;

cout<<"Enter Dollar Amount Of Sales This Month: ";
cin>> stm;
cout<<endl;

//Commission Processiong

if ( stm < 1200 ) {
commission = (stm-200) * 0.065;
} else {
commission = (stm-150) * 0.0725;
}
gross_pay = basepay + commission;

//Deductions

cout<<endl;
if ( gross_pay < 600 ) {
heath_contribution = h0;
} else
{
heath_contribution = healthi;
}

retirement = basepay * 0.09 + commission * 0.17;
taxes=gross_pay*.245;
Net=gross_pay-taxes-heath_contribution-retirement;
cout<<endl;

cout<<endl;

cout<<"\n                    BUDGET REPORT FOR "<<empn ;
cout<<"\nINCOME:" ;
cout<<"\nBase Pay:          \$"<<basepay ;
cout<<"\nSales:              \$"<<stm ;
cout<<"\nCommission:        \$"<<commission ;
cout<<"\nGross:              \$"<<gross_pay ;
cout<< endl;
cout<<"\n  Deductions:";
cout<<"\n  Health Insurance:\$" <<heath_contribution ;
cout<<"\n  Retirement:      \$-"<<retirement;
cout<<"\n  Taxes:          \$-"<<taxes    ;
cout<<endl;
cout<<"\n-----------------------------------------------------";
cout<< endl;
cout<<"\nNet:\$"<<Net;

return 0;
}

• 07-01-2003
Speedy5