hi i'm having a difficult time with the challenge assignment. I'm trying to remove in the script the second and third prompts, and replace them with the first prompt that starts when the button is clicked.     Programming Challenge     On Your Own:    5.7     Description:    Prompts user to enter as many integers as desired. The program                      will keep track of how many are odd and how many are even.                     At the end the sum and averages of all odds and evens are displayed.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

<!--------- hi i'm having a difficult time with the challenge assignment. I'm trying to remove in the script the second and third prompts, and replace them with the first prompt that starts when the button is clicked.
 

  Programming Challenge
    On Your Own:    5.7
    Description:    Prompts user to enter as many integers as desired. The program 
                    will keep track of how many are odd and how many are even.
                    At the end the sum and averages of all odds and evens are displayed.                

------------>
<html>
    <head>
        <title>Odds and Evens</title>
    </head>
    <body>
        <div style="width: 700px; margin: auto; margin-top: 100px; border: 1px solid black; padding: 5px; background-color: #E7E7E7;">
            <p style="font-weight: bold;">Lab 4b</p>
            <p>This program will keep track of odd and even integers entered by the user. At the end, the sum and average of the odds and the evens will be displayed.</p>
            <p>Begin the process by clicking on the 'BEGIN' button below.</p>
            <br /><hr /><br />
            <input type="button" onclick="oddsEvens()" value="< < BEGIN > >" />
            <div id="odd_result">&nbsp;</div>
            <div id="even_result">&nbsp;</div>
        </div>
       

 

<script>

 

    function oddsEvens()
            {
                do
                {
                    var userEntry = prompt('Enter any integer. Enter the word \"quit" and i\'ll leave you alone.');
                    console.log(userEntry);
                }while(userEntry != "quit");
            }
                

/*
        //Variable and array declaration

var arrayNum = [];
var arrayEven = []; 
var arrayOdd = []; 
var i; 
var NUM_INPUTS;  
var sumOdd = 0.0;
var sumEven = 0.0; 
var avgO = 0.0;
var avgE = 0.0;

NUM_INPUTS = parseInt(prompt("Enter the number of inputs you need: "));
for (i = 0; i < NUM_INPUTS; i++) {
  arrayNum.push(parseFloat(prompt("Enter the numbers: " + (i + 1))));
  if ((arrayNum[i] % 2) === 1) {
    arrayOdd.push(arrayNum[i]);
    sumOdd += arrayNum[i];
  }
  else {
    arrayEven.push(arrayNum[i]);
    sumEven += arrayNum[i];
    
  }
}
avgO = sumOdd / arrayOdd.length;
avgE = sumEven / arrayEven.length;
//Output results
document.write("All numbers in the array are: " + arrayNum);

document.write("<br/>All even numbers in the array are: " + arrayEven);
document.write("<br/> The sum of all even numbers is: " + sumEven + " and average of the even numbers is: " + avgE);

document.write("<br/>");
document.write("<br/>All odd numbers in the array are: " + arrayOdd);
document.write("<br/> The sum of all odd numbers is: " + sumOdd + " and the average of the odd numbers is " + avgO);
  
</script>
    </body>
</html>

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY