Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Question 16</title>
- </head>
- <body>
- <script>
- // Program that prompts a user to enter 10 numbers
- // and then adds them up.
- // A prompt is added part-way through asking if the
- // user wants to exit.
- var number = new Array();
- var total = 0;
- for (i=0; i<10; i++) number[i] = 0;
- for (i = 0; i < 10; i++)
- {
- number[i] = prompt("Enter a number.");
- if (i==3) {
- var quit = prompt("Wanna quit?");
- if (quit == "Y") break;
- }
- }
- for (i = 0; i < 10; i++)
- {
- total += parseFloat(number[i]);
- }
- alert(total);
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement