Design an online lottery game in C++ which will randomly store 6 number in the range of 1 to 30 as the winning numbers. Then it will ask the user to enter 6 numbers of their choice and match with the winning numbers. It should display the following: “Jackpot” for all 6 matches, “lucky five” for five matches, “super four” for four matches and “sorry, try again” for anything less than 4 matches. Your program should validate the input to be in the range of 1-30. It should also ensure that no values entered are repeated.
Question 1: Draw a flowchart for the above question
Question 2: Write a C++ program for the above situation.

Please can some help me in writing above program and drawing a flowchart on it.

PSUDO code would look something like this:

create 6 random numbers
for 0 to 6
    ask the user for a number
         \if ( number => 1 && number <= 30 )
              store input
              (this is where you may want to increment your varible for iteration )
         \else tell them they are doing the wrong thing

then

 \if ( 5 correct ) you will print lucky five <-- condition in your flowchart
 \if ( 4 correct ) print lucky four 
 \else try again

So represent the steps above as a flowchart

http://en.wikipedia.org/wiki/Flowchart

then attempt to program it, the flow chart should help you figure out the program logic.

Edited 2 Years Ago by Paul.Esson

Thanks so much for the information. I guess we also have to use arrays in this program,so would you be able to advice where we can use arrays. The program must give 6 different lucky numbers from the random numbers and store them. Then we have to input 6 numbers and match it with the lucky numbers and then the program should display output depending on the condition. Will the flowchart be same based on above.

Thanks
Ashneel Chand
ashneelchand93@yahoo.com

Well there are manny places you could use arrays in this one, but you could use vectors also. Don't hus about terminology.
Try to have one array that will be bool type, so now you have the abilyti to see wich one you have picked already.
Now you wait till you get reqired number. This you could achieve with one counter, and till number of picked numbers is less than 6 yo look for more of them, when you get one by chance you test is it in the array, if it is you dissmis him and look for another one. Also, if you don't like this way, you could like add 1 till you find one that you did not pick, and if you get at the end of array, well you just divide that number, or jou could just add it to firs one.

This article has been dead for over six months. Start a new discussion instead.