Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Change Calculator Starting with the downloadable assignment files, write the Jav

ID: 3720075 • Letter: C

Question

Change Calculator

Starting with the downloadable assignment files, write the Javascript needed for the application. Use the book and lectures as a guide. Develop an application to determine how many quarters, dimes, nickels and pennies are needed to make the desired change for any amount between 0 and 99. One way to get the results is to use the divide and modulus operators along with the parseInt() method for truncating the results so they are whole numbers.

Open the HTML and JavaScript files in the week 3 zip folder:

1.Run the application to see the user interface shown above. The interface won’t do anything until you develop the JavaScript for it. Add your first and last name to the title like this: FirstName LastName Change Calculator.

2. In the JavaScript file, note that the $ function has already been coded.

3. Code an event handler named processEntry() that gets the user’s entry and checks to make sure that it is a number between 0 and 99. If it isn’t, display an alert dialog box for the error. If it is valid, call a function named makeChange() and pass it the user’s entry.

4. Code the makeChange() function, which should have one parameter that accepts the user’s entry. This function shouldn’t return anything, but it should display the results in the text boxes for Quarters, Dimes, Nickels, and Pennies.

5. Code an onload event handler that attaches the processEntry() event handler to the click event of the Make Change button. Then, test the application.

Zip all files for submission. Add a screenshot of the running application on your computer showing the time/date on your screen at the time of testing.

Change Calculato Enter amount of change due (0-99) 6 Make Change Quarters Dimes: Nickels 1 Pennies

Explanation / Answer

<html>
<body>
<h2>Change Calculator</h2>
<label>Enter amount :- </label>
<input type="number" id="amt">
<button> Make change </button>
<br>
<label> Quater <span id="q"></span></label>
<br>
<label> Dime <span id="d"></span></label>
<br>
<label> Nickle <span id="n"></span></label>
<br>
<label> Pennie <span id="p"></span></label>

<script type="text/javascript">
function processEntry() {
let amt = parseInt(document.getElementById('amt').value);
if(amt >= 0 && amt < 100) {
// Conversion of amount should be done here.
makeChange(amt);
} else {
alert('Amount should be between 0 to 99')
}
}


function makeChange(amt) {
let q=0,d=0,n=0,p=0;
while(amt > 0) {
if(amt >= 25) {
q = Math.floor(amt / 25);
amt = Math.floor(amt % 25);
} else if(amt >= 10) {
d = Math.floor(amt / 10);
amt = Math.floor(amt % 10);
} else if(amt >= 5) {
n = Math.floor(amt / 5);
amt = Math.floor(amt % 5);
} else {
p = Math.floor(amt);
amt = amt % 1;
}
}
document.getElementById('q').innerHTML = q;
document.getElementById('d').innerHTML = d;
document.getElementById('n').innerHTML = n;
document.getElementById('p').innerHTML = p;
}
</script>
</body>
</html>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote