Challenge 9

💰

Lottery

Open in Code Editor or Copy Instructions
...solutions at bottom of page...

A person should be prompted to choose 6 numbers between 1-50. If the player choses a number they have already entered, they should be prompted to enter again, until they have 6 unique numbers

The program should then generate 6 unique, numbers between 1-50 - these will be the correct answers, that the player hopefully matched

If the player matches all 6, they win 50,000,000 of your chosen currency

If they match 5, they win 5,000,000, 4 correct wins 250,000 and so on, down to 0

Examples:

A player guessing {5,14,27,32,41,48} and the correct values being {3,27,19,36,41,25} would win for example 50 of the chosen currency, since their guesses of 27 and 41 were correct

Extension:

For A2 students/those who know, think about the data structures you are using - if you used an array, is there a more efficient data structure you could use instead?

Solutions

IGCSE 0478 / O-Level 2210 A-Level 9618