X Share

Java programming: Guessing games activities part two

Differentiation  Downloads  

Dave Duddell is back on the Brighter Thinking Blog, sharing three more activities to develop Java programming skills. In his previous blog post, Dave shared four tiered activities to support scaffolded learning in your programming class. Dave shares three activities to hone the Java skills of your more confident programmers, in this next installment.

In his previous blog post, Dave shared guessing game activities as demo, practice and challenge tasks. This three tiered approach to teaching allows learners to begin, develop and hone their programming skills through scaffolded learning. In this second instalment, Dave’s sharing three more guessing game challenge tasks, designed to stretch your strongest programmers.

Designed to support the Cambridge IGCSE™ and O Level Computer Science syllabuses (0478/0984/2210), each task develops programming skills for learners using Java. The skills include use of validation input, program testing, use of arrays and totalling standard method of solution and nested iteration.

These free activities are downloadable as worksheets for your learners to try in class, or at home. The question worksheet is ideal for confident programmers as it contains only the questions and so gives them free range to write a program themselves. The question and example worksheet is designed to support programmers who need a helping hand. Each task is supported by an example program, helping to guide less confident learners.

Challenge Task 1

A player is asked to provide a name and then to guess a number between 1 and 5. The player will be given 10 attempts. For each attempt a number is generated randomly. This number is output each time after the player has guessed a value. The number of correct guesses is output.

The aim of the task would be to demonstrate the use of a Java library routine. The inclusion of an output of each random number generated allows the user to check that the random number generator has been used correctly so that the range of random numbers generated is in fact from 1 to 5 inclusive.

 

Challenge Task 2

A player is asked to provide a name and then to guess a number between 1 and 10. The player will be given 5 attempts. For each attempt the input must be checked. If the value is not an integer, a message must be output. If the value is not in range, a message must be output. An error should not stop the program; the user must be allowed 5 attempts unless a correct guess is made causing the program to exit with a suitable message. After 5 unsuccessful attempts a sorry message is to be output.

The aim of the task is be to demonstrate the use of validation of input.  It can also be used as an example of program testing using the input of erroneous values.

 

Challenge Task 3

Two players are to compete in a guessing game and each player is asked to provide a name. However, the players do not supply values. Instead the program creates 5 random numbers for each player. The program has to output the five values for each player. Finally the result is output depending on the total of the 5 values for each player.

The aim of the task is to demonstrate the use of arrays, the totalling standard method of solution and nested iteration.

If you’d like to see more activities from Dave, take a look at his Java Programming Book and download your free sample.

Go back
X Share