
-----------------------------------
Quakerstate98
Mon Mar 24, 2008 1:44 pm

Having percentage calculation problem
-----------------------------------
I'm trying to build myself a budget program but my calculations for percent arnt working properly.

What i want is lets say u have a 400$ pay check
and u want to find out what 30% of that is and then put it into its own value
how would i go about doing so

-----------------------------------
michaelp
Mon Mar 24, 2008 1:51 pm

RE:Having percentage calculation problem
-----------------------------------
You say your calculations aren't working? What do you mean?
And you would multiply the paycheck by 0.3 to get 30% of it.

-----------------------------------
syntax_error
Mon Mar 24, 2008 1:55 pm

Re: Having percentage calculation problem
-----------------------------------

double paycheck=400;
double balance =0;

balance =paycheck*0.3;

printf ("%.2d"+ balance);


?

-----------------------------------
Saad
Mon Mar 24, 2008 2:01 pm

Re: Having percentage calculation problem
-----------------------------------


double paycheck=400;
double balance =0;

balance =paycheck*0.3;

printf ("%.2d"+ balance);


?


Why are you using printf, printf is a C function to output items to a screen, you should be using std::cout since this is C++ not C.

Further more the code can be shortened a bit more to

double paycheck=400;
double balance = paycheck * 0.3;



Saad

-----------------------------------
syntax_error
Mon Mar 24, 2008 2:26 pm

RE:Having percentage calculation problem
-----------------------------------
srry it was more of a prosudo code then a full solution

-----------------------------------
michaelp
Mon Mar 24, 2008 3:30 pm

RE:Having percentage calculation problem
-----------------------------------
Those calculations should work, if they don't already.
