Counting Coins - How Do?

Set up your counting coins assignment much like your equations assignment. Have 4 HTML elements with 4 unique IDs. Create variables for pennies, nickels, dimes, quarters and a total using whole numbers. Decide a value for a total, your value should be more than a dollar, but not too high. In my example, I'm using 128 cents. My example shows 2 combinations, your assignment should have 4.

<p id="count1"></p>
<p id="count2"></p>

<script>
var penny = 0.01;
var nickel = 0.05;
var dime = 0.10;
var quarter = 0.25;
var total = 1.28;

document.getElementById("count1").innerHTML = total + " is (quarter * 5) + (penny * 3) = " + ((quarter * 5) + (penny * 3));
document.getElementById("count2").innerHTML = total + " is (penny * 128) = " + (penny * 128);
</script>

The output on your page will look something like this:




back to index