Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This application will give you a chance to use a for loop. Use the prompt dialog box to ask the user to enter a number

This application will give you a chance to use a for loop. Use the prompt dialog box to ask the user to enter a number from 1 through 100.

Then, display a dialog box asking the user if they want to enter another number. The user will enter y or n. If the user enters y, input the next number 1 through 100, then ask if they want to enter another number.

Finally, it adds all the numbers from each of the users entries and displays the sum of the numbers in the page like this:

The sum of the numbers 1 - 5 is 15.

The sum of the numbers 1 - 89 is 4005.

Open this HTML file:

exercises_extra\ch03\sum_numbers.html

In the script element, add a do-while loop that prompts the user for an entry from 1 through 100. If the entry is invalid, display an alert box with this message: Please enter a number between 1 and 100. Then, continue the loop until the entry is valid.

After the do-while loop, code a for loop that sums the numbers, and then display the second dialog box above. For instance, the sum for an entry of 4 is 1 + 2 + 3 + 4.

Add a do-while loop around all of the code that uses the second dialog box above to determine whether the first dialog box should be displayed again so the user can enter another number. The application should end for any entry other than y.

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

The Database Relational Model A Retrospective Review And Analysis

Authors: C. J. Date

1st Edition

0201612941, 978-0201612943

More Books

Students also viewed these Databases questions