Posted: Mon Mar 24, 2008 1:44 pm Post subject: 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
Sponsor Sponsor
michaelp
Posted: Mon Mar 24, 2008 1:51 pm Post subject: 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
Posted: Mon Mar 24, 2008 1:55 pm Post subject: Re: Having percentage calculation problem
code:
double paycheck=400;
double balance =0;
balance =paycheck*0.3;
printf ("%.2d"+ balance);
?
Saad
Posted: Mon Mar 24, 2008 2:01 pm Post subject: Re: Having percentage calculation problem
syntax_error wrote:
code:
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