Hey i'm currently developing a php console mode program for a client. It is a tax program that prompts the user the annual gross income, calculates the tax payable and then displays the gross income and mount of tax payable. Here is the code, #!/usr/local/bin/php -q <?php //tax.php require ("phpio"); $gross = 0; $tax = 0.0; print ("\n\n Enter annual gross income: "); $gross = input(); if ($gross >= 6001 && $gross <= 35000 ) { $tax = $gross - 6000; $tax = $tax * 0.15; } if ($gross >= 35001 && $gross <= 80000) { $tax = $gross - 35000; $tax = $tax * 0.30; $tax = $tax + 4350; } if ($gross >= 80001 && $gross <=180000) { $tax = $gross - 80000; $tax = $tax * 0.38; $tax = $tax + 17850; } if ($gross >= 180001) { $tax = $gross - 180000; $tax = $tax * 0.45; $tax = $tax + 55850; } print ("\nGross pay is:\n"); print ("$ $gross\n\n"); print ("Tax payable:\n"); print ("$ $tax\n\n "); ?> Code (markup): There is one problem with it. If the user reports tax on 35001 and it is 4350.3. But i want it to display 4350.30. How would i do this. Any help would be much appreciated.
try money_format : http://www.php.net/manual/en/function.money-format.php it doesn't work on windows though so you might have to go with number_format and if that still isn't good enough there's always sprintf http://www.php.net/manual/en/function.sprintf.php