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

The Computer needs to Guess the number, not the user Using your JSFiddle account

ID: 3674453 • Letter: T

Question

The Computer needs to Guess the number, not the user Using your JSFiddle account you are going to create a guessing game, only it will be the computer doing the guessing. Here is how it works - the computer will ask you for a number between 1 and 1000, it will check first to make sure your input is within the bounds. Once you enter the number it will guess the number and do a comparison with the number you entered. It will output the results of the guess and continue to do this until it gets the correct answer. Programming parameters: 1 - This will be coded in Javascript. 2 - You should create a dimensioned array of 1000 elements. 3 - You should fill in the elements from 1 to 1000 in order prior to implementing the search The point is for the computer to be guessing the number.

Explanation / Answer

<html>
<head>
   <script language="Javascript">
       var n=prompt("Enter number between

1 to 1000");
       var n1=0, r=0;
   </script>
</head>
<body>
   <script language="Javascript">
       n1=eval(n);
       if(n1>0 && n1<1001)
       {
           r=(Math.random()*1000)+1  

;
           if(n1==r)
               document.write

("Numbers are equal");
           else
               document.write

("Numbers are not equal");

       }
   </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