0% found this document useful (0 votes)
9 views7 pages

BIS102 Assessment 2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views7 pages

BIS102 Assessment 2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

BIS5102 Programming Fundamentals

Assessment 2
Assignment Description

This assignment will give you practical exposure with interactive programs, if/else
statements, methods that return values, and while loops.

John is looking at developing a guessing game. The guessing game program


generates a random number and allows the user to make guesses until the user gets
it right. For each incorrect guess, the program tells the user whether the right answer
is higher or lower. After a correct guess by the user, the program prompts the user if
wants to play the game again, if the user chooses not (No) to play again the program
displays the various statistics about the series of games played by the user as
shown in the example log of execution below. Your program output must be exactly
as the example log provided.

Example Log of execution (user input underlined)

~~~ Guessing game ~~~

I will think of a number between 1 and 100

Please make a guess of my number. For each guess, I will tell you whether the

right answer (my number) is higher or lower than your guess.

I'm thinking of a number...

Your guess? 20

higher

Your guess? 40

higher

Your guess? 60

higher

Your guess? 80

Apex Australia Higher Education, CRICOS Provider No. 03967J; PRV14320, ABN: 45 615 071 853.
higher

Your guess? 100

lower

Your guess? 90

lower

Your guess? 88

lower

Your guess? 86

You got it right in 8 guesses

Would you like to play again? (Press ‘Yes’ or ‘No’): Yes

I'm thinking of a number...

Your guess? 20

higher

Your guess? 40

higher

Your guess? 60

higher

Your guess? 80

higher

Your guess? 82

higher

Your guess? 84

higher

Your guess? 86

Apex Australia Higher Education, CRICOS Provider No. 03967J; PRV14320, ABN: 45 615 071 853.
higher

Your guess? 88

higher

Your guess? 90

higher

Your guess? 92

higher

Your guess? 94

lower

Your guess? 93

You got it right in 12 guesses

Would you like to play again? (Press ‘Yes’ or ‘No’): Yes

I'm thinking of a number...

Your guess? 20

higher

Your guess? 40

higher

Your guess? 60

lower

Your guess? 58

lower

Your guess? 56

You got it right in 5 guesses

Would you like to play again? (Press ‘Yes’ or ‘No’): No

Apex Australia Higher Education, CRICOS Provider No. 03967J; PRV14320, ABN: 45 615 071 853.
Overall results:

Total games = 3

Total guesses = 25

Average guesses/game = 8.33

Max guesses = 12

Tasks to be completed for Assignment-1

1. Design a Flowchart that meets the program specification given above.

2. Translate your design to a Python code. The program should be stored in a file
called ApexXXX.py where ApexXXX is your student ID.

3. Define a class constant for the maximum number (MAX_GUESS) that the user
can guess.

4. Correctly implement the following static methods in addition to method main:

a) A method that generates a random number between 1 and maximum


number defined in 3 (this method has been generated for you in the ApexXXXGuess
class)

b) A method to give instructions to the user

c) A method to play one game with the user

5. When you ask the user whether or not to play again, you should use the “next()”
method of the Scanner class to read a one-word answer from the user. You should
continue playing if this answer begins with the letter “y” or the letter “Y”. Notice that
the user can type words like “yes”. You have to look just at the first letter of the user’s
response and see whether it begins with a “y” or “n” (either capitalized or not) to
determine whether to play again.

6. At the end of the log you should print a summary report about the series of games
played by the user, these being the total number of games played (use a variable to

Apex Australia Higher Education, CRICOS Provider No. 03967J; PRV14320, ABN: 45 615 071 853.
keep track of this), the total number of guesses (Max guesses) made (use another
variable to keep track of this), and the average number of guesses per game.

Marking criteria: Program Demonstration: Students must demonstrate their


program in week12 (lab time) to the tutor and are expected to explain their
implementation. Marks will be deducted (50% -maximum) for no demonstration or
poor explanation.

Marking criteria is shown in following table. Marks are allocated as follows:


Tasks Marks
Task 1
1. Comments describing program, author and date are included 1
2. Import statement is included 0.5
3. Naming convention of class is followed appropriately 0.5
Task 2
Class constant is declared and initialised 2
Task 3
1. Correctly calls method that generates random number 1
2. Method to print instructions is correctly declared 2
3. Method to play game is implemented and runs successfully 10
Task 4
1. Implements a loop to allow the game to continue running until the 5
user quits
2. Successfully uses the scanner and if-else statements to check if 5
user wants to continue playing
Task 5
Method to report overall results is implemented and runs successfully 7
Others
1. Use whitespaces (vertical & indentation) properly to make program 2
more readable.
2. Give meaningful names to methods and variables in your code. 2
3. Localize variables whenever possible -- that is, declare them in the 2
smallest scope in which they are needed.

Apex Australia Higher Education, CRICOS Provider No. 03967J; PRV14320, ABN: 45 615 071 853.
4. Your program compiles successfully without any errors 5
5. Your program is interactive and gives correct output 5
Total Marks 50
Marking Rubric for Assignment 2: Total Marks 50

HD 40-50 D 35-39 CR 30-34 P 25-29 Fail <25


Excellent Very Good Good Satisfactory Unsatisfactor
y
Program is well Program is Generally, Program does This is not
documented, includes well well not follow stated relevant to the
import statements to documented documented requirements assignment
support external but has a few and named requirements.
classes and the class minor issues but has
name is named some issues
appropriately
Constant is declared Constant is Constant is Constant is This is not
appropriately declared but declared but declared but not relevant to the
not as per has some as per assignment
specification issues requirements requirements.
Method Method Method Method design No methods
design and design and design and and or method
implementatio implementatio implementati implementation implementatio
n is clear and n is consistent on is mostly is adequate but n is incorrect
easy-to-follow consistent misses the
requirements
Loop is correctly and Loop is Part of the Most No loop used,
successfully used implemented loop is components or
correctly and implemente present implementatio
works d and works n is incorrect
but does not
meet all the
requirement
s
Method to output Method to Good effort Made some Output is
results is well output results made but effort. incorrect, or

Apex Australia Higher Education, CRICOS Provider No. 03967J; PRV14320, ABN: 45 615 071 853.
implemented and runs is mostly well not method not
successfully implemented outstanding implemented
Follows syntax rules Very good Good effort Made some Program
and Python effort is made made but effort completely
programming in following not fails to
conventions, program Python syntax outstanding compile and
runs correctly and run
conventions

Apex Australia Higher Education, CRICOS Provider No. 03967J; PRV14320, ABN: 45 615 071 853.

You might also like