Picking Lottery Numbers

 

4 points

 

Introduction

The New Jersey Lottery has a game called Pick-6, in which a player chooses 6 numbers between 1 and 49 (inclusive). This app generates 6 random integers between 1 and 49 that a player might use in playing Pick-6. This could take place inside a FOR loop that runs 6 times (but it can also be done without using a loop). After each number is generated by the random-number generator, it is added onto a string. After all 6 numbers have been generated, the resulting string is displayed in a Label. A Label that says "The numbers are:" and the Label that displays the 6 numbers are then made visible using 'showElement'.

Here is a link to App Lab documentation:

 

Extra Credit (4 points)

A problem with the approach outlined above is that it is possible that a given number will appear more than once. And in Pick-6, you cannot use a number more than once. For this extra-credit, you upgrade the program so that all 6 numbers are unique. You'll want to use a WHILE loop instead of a FOR loop. You can also use the includes() function, in an IF statement, to check whether the cumulative string of numbers already includes a given number.

Additional links:

 

Video

The video shows what a completed app should do.