Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JavaScript functions Assignment04B In this assignment, students will create a change-counting game that gets the user to enter the number of coins required to make

JavaScript functions

Assignment04B

In this assignment, students will create a change-counting game that gets the user to enter the number of coins required to make exactly one dollar. The program should accept from the user the number of pennies, nickels, dimes, and quarters. The program calls a function to calculate the total, and returns a string message.

Complete the solution by writing code in the addUpChangefunction.

Notes:.

If the total value of the coins entered is equal to one dollar, the function should return a string that congratulates the user for winning the game.b.

This is the EXACTconfirmation text you should use:

You win. That is exactly$1.00!

Otherwise, the function should return a string indicating whether the amount entered was more than or less than one dollar. Examples of this message appear below. Please follow the pattern of the message exactly.

You lose. 0.48 is less than $1.00

You lose. 1.23 is more than $1.00

If the user provides any piece of data that is not numeric, the function should return this EXACTerror message: Bad data. Please try again.

Test your work.

image text in transcribed

2 UL 5 5 7 3 // Create a change-counting game that gets the user to enter the number of coins 1 required to make exactly one dollar. The program should accept from the user // the number of pennies, nickels, dimes, and quarters. The program calls a function // to calculate the total, and return a string message. 9 1 2 // If the total value of the coins entered is equal to one // dollar, the function should return a string that congratulates the user for // winning the game. 7 // This is the EXACT confirmation text you should use: // You win. That is exacly $1.00! // Otherwise, the function sould return a string indicating // whether the amount entered was more than or less than one dollar. // Examples of this message appear below. Please follow the // pattern of the message exacly. 2 1 3 1 // You lose. 0.48 is less than $1.00, // You lose. 1.23 is more than $1.00 5 // If the user provides any piece of data that is not numeric, the function // should return this is the EXACT error message: // Bad data. Please try again

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Principles Programming And Performance

Authors: Patrick O'Neil

1st Edition

1558603921, 978-1558603929

More Books

Students also viewed these Databases questions

Question

Write formal and informal proposals.

Answered: 1 week ago

Question

Describe the components of a formal report.

Answered: 1 week ago

Question

Write formal and informal reports.

Answered: 1 week ago