On This Page
Overview
During this assignment, you will:
- Write a "guess the number" game
- Decide how to organize your program into methods
- Write a method to validate user input
^ top
Specifications
Write a program that plays "guess the number" as follows:
- Your program randomly chooses a number to guess between 1 and 100.
- Your program displays instructions and a prompt to guess a number.

- If the player types an incorrect guess, your program displays the number and whether it is too high or too low. This allows the player to "zero in" on the answer.


- When the player guesses the correct answer, your program evaluates their play based on the number of guesses made.

- If the count is less than 7, display "Either you know the secret or you got lucky!"
- If the count is exactly 7, display "Congratulations! You know the secret!"
- Otherwise, display "You should be able to do better!"
Additional Specifications
- The name of the program source code file must be
GuessingGame.java.
- One of your program methods must be
public static int inputInt(String prompt). The method prompts the user to enter an int value, reads the value from the keyboard, verifies that a correct int was entered and returns the entry as an int. If the user presses the cancel button, the program exits.
- Your program must validate user input and handle all error conditions.

- Whenever the user presses the Cancel button, the program exits.

- Do not use packages statements
^ top
Extra Credit
The following are worth extra credit points:
- Complete the assignment using pair programming. (1 point)
- Explain in your README.txt file why it should take no more than 7 guesses for 100 numbers. (1 point)
- The maximum number of guesses anyone should need for 100 numbers is 7 and the maximum number of guesses for 1000 numbers is 10. Implement a formula in your program that will work for any range of positive
int values. (1 point)
Make certain that your README.txt file describes any extra credit attempted.
^ top
Grading Criteria
The instructor will evaluate your assignment using the following criteria. Each criteria represents a specific achievement of your assignment and has a scoring guide. The scoring guide explains the possible scores you can receive.
Some scoring guides have a list of indicators. These indicators are a sign of meeting, or a symptom of not meeting, the specific criterion. Note that a single indicator may not always be reliable or appropriate in a given context. However, as a group, they show the condition of meeting the criterion.
For information on grading policies, including interpretation of scores, see the course information page.
Program Compilation
- 4: Source code compiles with no errors or warnings
- 2: Source code compiles with warnings
- 0: Does not compile or wrong file turned in
Functionality
- 10: Demonstrates mastery of the assignment
- Has extra features or demonstrates techniques beyond the assignment
- Applies concepts from the lesson(s) appropriately
- Meets all specifications (see above) with particularly elegant solutions
- Runs to completion with no abnormal error conditions
- Generates correct output given correct input
- Behaves in a reasonable way in response to incorrect data
- Code is organized well into methods
- 8: Has all the functionality expected of the assignment
- Demonstrates many techniques from the lesson
- Meets all specifications (see above)
- Implementation seems more complicated than necessary.
- May have one minor error
- All test cases pass
- 6: Has most of the functionality expected of the assignment
- Demonstrates some techniques from the lesson
- Meets all but one of the specifications (see above)
- Implementation seems excessively complicated.
- May have 2-3 minor errors
- All but one test case passes
- 4: Has some of the functionality expected of the assignment
- Demonstrates some techniques from the lesson
- Meets at least 1/2 of the specifications (see above)
- Implementation seems excessively complicated.
- May have more than 3 minor errors
- At least 1/2 of all test cases pass
- 2: Serious functional problems but shows some effort and understanding
- Meets less than 1/2 of the of the specifications (see above)
- Has a major error or many minor errors
- Implementation seems very convoluted
- Demonstrates few techniques from the lesson
- Less than 1/2 of all test cases pass
- 0: Does not execute or no specifications met
Programming Style
- 4: Code is well-documented
- 3: Code has minor documentation errors
- Has 1 documentation error
- 2: Code has some documentation errors
- Has 2-3 documentation errors
- 1: Code has many documentation errors
- Has more than 3 documentation errors
- 0: No apparent attempt to document code
REAME.txt File
- 2: README.txt file submitted with specified information included
- 1: README.txt submitted but some information was not included
- 0: No README.txt submitted
Maximum Score: 20, plus extra credit
^ top
What to Turn In
Submit your assignment following the instructions for homework. Include the following items for grading:
README.txt file
GuessingGame.java
- Any other source code needed to make your program function.
You must submit all the files needed to make your assignment function properly. Do not assume that the instructors has any files unless explicitly stated by the instructor. Your assignment must work as submitted.
^ top
Home
| WebCT
| Announcements
| Schedule
| Expectations
| Course info
Help
| FAQ's
| HowTo's
| Links
Last Updated: October 29 2004 @16:42:15
|