I need to compose a program that simulates a lottery. the program should have an array of 5 integers named lottery and should generate a random number in the range of 0 through 9 for each element in the array. the user should enter five digits which should be stored in a integer array named user. the program is to compare the corresponding elements and keep a count of the digits that match. The program should display the random number stored in the lottery array and the numbers of matching digits. If all of the digits match, display a message proclaiming the user as a grand prize winner. This program is due on 4/27/2012. I am very hopeful that someone can assist me in getting it started. I don't have any code done yet, has I just learned of the task.
Why not write down a plan of exactly what you want to do, in English. There's no point in starting to write code if you don't know what you're doing. Figure out what you want to do and start coding.
Most pseudo-code is very abstract, but I'll start with something that you can easily apply:
Generate a random number from 0-9 and place it in the first element of the array
Generate a random number from 0-9 and place it in the second element of the array
...
Generate a random-number from 0-9 and place it in the fifth element of the array
Ask the user to enter five numbers
Enter the first number into the first element of the array
etc...
Compare the first element of the user array with the first element of the lottery array
If the two numbers are equal, store the number and increase the number of matching numbers
etc...
I have a question though: Are any of the lottery/user numbers allowed to be the same?
If they aren't, you need to make sure you implement that.
If the are, how are you going to check the user input with the lottery array? Surely, if the lottery array contains two 5s and the user array contains two 5s, they only got 2 matches not 4. Make sure that once a lottery number has been matched, you do not check it again. Make sure that once you have found a match for a user number, you stop looking too.