Due: Tuesday, Feb. 10th by 8:00pm
This MP, like all MPs in CS 105, is a solo assignment. Review the course syllabus to understand exactly what is expected of you when it comes to academic integrity.
To get started, you will first need to download the base files for MP1 here. The file you downloaded is a ZIP file and must be extracted before it can be used.
Once extracted, you should have a directory that has exactly two files: mp1.html and mp1.js. By default mp1.html will open up in a web browser, which should display the MP1 web page. If you attempt to guess a number, you will notice that it does not work since we have not programmed it to do anything yet!
Open up mp1.html in a plain text editor and complete the following:
<input type="button" value="Guess!">
value="Guess!"but before the
>, we will add a new attribute to the HTML tag. Add
onclick="processGuess()", making sure to leave at least one space between the new attribute and value attribute.
<input type="button" value="Guess!" onclick="processGuess()">
processGuess() when the button on the
web page is clicked. Make sure to save your HTML and then to test that you did this correctly before starting on Part 2!
To check if you have completed Part 1, open (or reload) your MP1 HTML page inside of a web browser. After refreshing, enter a number into the text box and press "Check!":
For Part 2, you must complete the checkNumber function that is found in mp1.js. The checkNumber function has two parameters:
secretNumber, the randomly generated secret number (a number in the range 1-100)
guessedNumber, the number that was guessed by the user
With those two parameters, the checkNumber function must do the following:
"Guess Smaller"if the user should guess a smaller number next time in order to get to the random number.
"Guess Larger"if the user should guess a larger number next time in order to get to the random number.
"Correct"if the user guessed the number correctly.
When you are ready to test Part 2, make sure to save the mp1.js file and then open or refresh the mp1.html page in a web browser. Enter a number into the text box and press "Check!":
Due to the very simple nature of this MP, there will be no partial credit. You should make sure your MP works completely before submitting it.