Lotto
Program – Version 1
Assume
you’d like to simulate the LOTTO game.
People pick 5 numbers between 1 (inclusive) and 47 (inclusive). After people have picked their lotto numbers,
the winning lotto numbers are drawn randomly.
Write
a program that allows the user to pick 5 numbers within the lotto range. Use a data validation loop to ensure that
they pick 5 numbers that are within range.
After
the user has picked their 5 numbers, the computer should randomly generate 5
numbers that are also within the lotto range.
Finally,
the program should display both sets of numbers on the screen so the user can
compare to see how many matches they have.
Use
top down design to separate program into logical tasks.
Lotto
Program – Version 2
As it
stands, there’s nothing stopping the user from choosing any number more than
once. The user could even enter 45 as
all 5 of their numbers. (It certainly
wouldn’t help their chances of winning the lotto, but your program allows
it.) Adjust your program so that the
user can’t pick the same number twice (or more).
Also,
adjust your code so that the computer won’t randomly select the same number
twice (or more).
Hint: You’re adding information to you DATA
VALIDATION. Not only must the number be
between 1 and 47, but also it must also not be already chosen