Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

How to calculate a number that is used by the number format?

$
0
0
Hi! i had a problem a about calculating the numbers:

the instruction is to declare a variable with a value of 150000 and placed a number format.
so i used it like this:
$value1 = number_format (150000,2);

then, the value is first displayed:
i add the dollar sign from the first so that when i displayed it in the browser, the dollar sign appears.
printf ("$ $value1");

next thing is to calculate the value1 with a 10% increase:
i used this
$finalvalue = $c1 * 0.1 + $c1;
or this
$finalvalue = number_format ($c2 * 0.1 + $c2, 2);

then, when i saw it in the browser the value is wrong.

the calculation should be like this:

150000 * 0.1 + 150000 = 165000
but the instructions said that the output of it must be in the format like this:
$ 165,000.00

so what am i going to do? when i used that formula above, the calculation goes wrong like this:
$ 165.00

any help will be appreciated. thanks! :)

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>