What Do you Think is wrong?

To get the gross
(multiply hours worked to Hourly rate)
To get the retirement
(multiply gross to 7percent)
To get the Taxes
(multiply gross to 20percent)
To get the Net
(add Retirement and Taxes)

The program should display
Gross: 459.20
Retirement: 32.14
Taxes: 85.41
Net: 341.64


BUT This my hand out.


#include<iostream>
#include<string>
using namespace std;

int main()
{
string name;
double hours,rate;
double gros,ret,tax,net;
cout<<"Please Enter Employee's Name:\n\n";
cin>>name;
cout<<"Please Enter Hours Worked:\n\n";
cin>>hours;
cout<<"Please Enter Hourly Rate:\n\n";
cin>>rate;
gros=hours*rate;
ret=gros*.7;
tax=gros*.20;
net=ret+tax;
cout<<"EMPLOYEE:" <<name <<endl;
cout<<"Gross:\t" <<gros <<endl;
cout<<"Retirement:\t" <<ret <<endl;
cout<<"Taxes:\t" <<tax <<endl;
cout<<"Net:\t" <<net <<endl;
system("pause");
return 0;
}


instead of this
The program should display
Gross: 459.20
Retirement: 32.14
Taxes: 85.41
Net: 341.64

My Hand out display different. Our Instructors told us to input 56 on hours work and 8.20 on hourly rate.
Gross:459.20
Retirement:321.44
Taxes: 91.84
Net:413.28

this is my difficulties please help.. thanks a lot and god bless
@Jemar

First, please always use code tags, edit your post, select all the code, press the <> on the right under the format menu.

Can you tell us what 7% is as a decimal fraction?

17
18
19
ret=gros*.7;
tax=gros*.20;
net=ret+tax;


I always specify a double literal explicitly, numbers before & after the decimal point :

tax=gros * 0.20 ;
@TheIdeasMan

the decimal fraction of 7% is 0.07


I already fix the problem on retirement but also the same the problem on
tax and net


even though I've change the 20% to 1/5 or 0.20


do a bit math. the tax is obviously not directly from gross
@coder777

Thanks buddy for the making me Think what should i do.
now i solved the problem

instead of this
tax=gros*.20;

i change it to
tax=(gros-ret)*.20

and

net=ret+tax;

i change it to
net=gros-(ret+tax);

LOL Ive done a bit math as you say ^_^
Topic archived. No new replies allowed.