Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

just code should be in javascript Coin Counter: Create a small script that accepts a number (use a prompt box) and converts that into coins.

just code should be in javascript

Coin Counter: Create a small script that accepts a number (use a prompt box) and converts that into coins. Use American money - quarters(25), dimes (10), nickels (5), and pennies (1). 

For example, if I entered 37, I would receive an answer of quarter, dime, and two pennies. If I entered 118, I would receive an answer of 4 quarters, 1 dime, one nickel, and three pennies.Coin Counter:

here,s what i got so far

<html>

<script>

"use strict";

var $ = function (id) { return document.getElementById(id); };

var calculateChange = function() {

  var cents, quarters, dimes, nickels, pennies;

  // get the number of cents from the user

  coins.cents = Math.floor(parseInt($("cents").value));

  if (!coins.isValid()) {

    alert("Please enter a valid number");

  } else {

    quarters = coins.getNumber(25)

    dimes = coins.getNumber(10)

    nickels = coins.getNumber(5)

    pennies = coins.cents

    // display the results of the calculations

    $("quarters").value = quarters;

    $("dimes").value = dimes;

    $("nickels").value = nickels;

    $("pennies").value = pennies;

  }

};

window.onload = function () {

  $("calculate").onclick = calculateChange;

  $("cents").focus();

};

  </script>

  </html>

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question