| This is the A348/A548 Fall 2001 Midterm Exam.
|
Please write your name or username here: ____________________
This exam has two parts.
- Read the problem below and provide your answer, turn it
in within 75 minutes.
- Take this exam home and turn in your revised answers
by Tuesday (10/23) 5:30pm.
For part 2 turning in means posting the source code in protected,
working prototype on your server.
Please note:
- Part 1 is mandatory.
- Part 2 is optional.
- Your grade will be based on the average
of your grades on Part 1 and Part 2.
- The exam is open-book, open-notes.
Here now is the text of the problem.
PROBLEM
Use PHP or Perl/CGI to implement the following game.
Your program starts by choosing a random number between 1 and 100.
It then offers the user 10 chances to guess the number. Each time the
user enters a number the program replies in one of three ways:
- if the user enters a number that's bigger than the secret number the
program reports that and also counts the attempt. If the number of attempts
becomes bigger than 10 the user has lost, is notified, and number is shown.
- if the user enters a number that's smaller than the secret number the
program reports that and also counts the attempt. If the number of attempts
becomes bigger than 10 the user has lost, is notified, and number is shown.
- if the user has guessed the number then the user is notified, congratulated.
The interface should be an HTML form with one text field and one submit button.
Comments:
- This is almost identical to the calculator program of homework 2 and 3
- Instead of a running balance we keep track of a running number of attempts
- We also carry around a secret number that doesn't change
- Each time user submits a number the number submitted is checked against the
secret number
- Assume an honest user that never tries to cheat on you in any way
GRADUATE STANDING:
- Add a Reset button, that restarts the game.
This exam is
Good luck and do well!