PROBLEM: Philippine currency is broken down into 1000, 500, 100, 50, 20, 10, 5 and 1 peso coin. Write a PHP script that would accept an integer amount in peso and output the smallest bills and coins that would add up to that amount. Output the result using input boxes and marked then as read-only.
PHP:
<!DOCTYPE html>
<html>
<body>
<form action = "" method = "post">
Enter Amount : <input type="text" name="currency">
<input type="submit" value="GENERATE" name="amount"/>
</form>
<?php
if(isset($submit['currency']))
{
$currency = $submit['amount'])
$one_thou = $amount/1000;
$one_thour = fmod($amount,1000);
$five_hun = $one_thour/500;
$five_hunr = fmod($one_thour,500);
$one_hun = $five_hunr/100;
$one_hunr = fmod($five_hunr,100);
$fifty = $one_hunr/50;
$fifty_r = fmod($one_hunr,50);
$twenty = $fifty_r/20;
$twenty_r = fmod($fifty_r,20);
$ten = $twenty_r/10;
$ten_r = fmod($twenty_r,10);
$five = $ten_r/5;
$five_r = fmod($ten_r,5);
$one = $five_r/1;
echo "<br> P1000 Bills: ".$one_thou;
echo "<br> P500 Bills: ".$five_hun;
echo "<br> P100 Bills: ".$one_hun;
echo "<br> P50 Bills: ".$fifty;
echo "<br> P20 Bills: ".$twenty;
echo "<br> P10 Coins: ".$ten;
echo "<br> P5 Coins: ".$five;
echo "<br> P1 Coins: ".$one;
}
?>
</body>
</html>
Attachments
-
You do not have permission to view the full content of this post. Log in or register now.