Java Program For Lottery Ticket

2020. 2. 28. 08:00카테고리 없음

Java ProgramOnce there was a lottery system started. In every lotteryticket, there was a number based on which winner was selected. Oneof the hacker hacked the algorithm that was used to select thewinner. The algorithm was simply easy.

Java Program For Lottery Ticket

Java Lottery Game

According to this algorithm,all the sub numbers that are derived from the lottery number mustremain the sub number of the lottery number even if they arereversed. If these criteria are satisfied then the lottery numberis selected as the winner. Your task is to create a program toidentify whether the given lottery number wins or not. Expert Answer 100% (1 rating).

Anytime you do a rand you can get the same number more than once.So, when you generate your lotto number you need to check if you have already received that number, and if so, call rand again until you get a number you have not received.The easiest thing to do is add an array of 10 int as an edit mask. Initialize each element of this array to 0.You now map your rand%10 number, which must be between 0 and 9 to this 10 int array. If your rand%10 is 5, then look at the array5. If array5 is 0 you have not received a 5 so change array5 to 1.On the other and, if array5 is 1, then you have already received a 5 and you should call rand%10 again.