<?php
$originalAmount=$_POST{'value'}
//convert input to an integer
$Amount=('integer')$originalAmount;
//get the number of quarters
$quarter= $Amount/25;
//get remainder
$amount=$Amount%25;
//out of the remainder, find how many 10s are in it and repeat the process
$dimes=$amount/10;
$amount=$amount%10;
$nickels=$amount/5;
$amount=$amount%5;
$pennies=$amount/1;
$amount=$amount%1;
//print results onto the screen
print (($originalAmount). "Can be given as:");
print "<br>";
print ((integer)$quarters. "quarters");
print "<br>";
print ((integer)$dimes. "dimes");
print "<br>";
print ((integer)$nickels. "nickels");
print "<br>";
print ((integer)$pennies. "pennies");
print "<br>";
?>
And my HTML
<head> <title>Change Maker</title> </head> <body> <form action="ChangeMaker.php" method="post"> Convert to change <input type='number' name='value'> <br></br> <input type=submit value="Make Change"> </form> </body>

New Topic/Question
Reply



MultiQuote





|