Need Help ppl
Grasshopper
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.
Eto yung code ko:
____________
<!DOCTYPE html>
<html>
<body>
<?php
function countCurrency($amount)
{
$notes = array(1000 , 500, 100, 50, 20, 10, 5, 1);
$noteCounter = array(0, 0, 0, 0, 0, 0, 0, 0, 0);
for ($i = 0; $i < 9; $i++)
{
if ($amount >= $notes[$i]){
$noteCounter[$i] = intval ($amount / $notes[$i]);
$amount = $amount - $noteCounter[$i] * $notes[$i];
}
}
echo ("Enter Amount: 3998 "."<br> \n");
for ($i = 0; $i < 9; $i++)
{
if ($noteCounter[$i] != 0){
echo ($notes[$i] . "bills : " . $noteCounter[$i] . "<br> \n");
}
}
}
$amount = 3998;
countCurrency($amount);
?>
</body>
</html>
Eto yung code ko:
____________
<!DOCTYPE html>
<html>
<body>
<?php
function countCurrency($amount)
{
$notes = array(1000 , 500, 100, 50, 20, 10, 5, 1);
$noteCounter = array(0, 0, 0, 0, 0, 0, 0, 0, 0);
for ($i = 0; $i < 9; $i++)
{
if ($amount >= $notes[$i]){
$noteCounter[$i] = intval ($amount / $notes[$i]);
$amount = $amount - $noteCounter[$i] * $notes[$i];
}
}
echo ("Enter Amount: 3998 "."<br> \n");
for ($i = 0; $i < 9; $i++)
{
if ($noteCounter[$i] != 0){
echo ($notes[$i] . "bills : " . $noteCounter[$i] . "<br> \n");
}
}
}
$amount = 3998;
countCurrency($amount);
?>
</body>
</html>