That's what i have so far.Code:/* Make a lottery program Picks 7 random numbers Asks the user for 7 numbers Checks how many match they can be in any order, like the first number the user chooses can match the 4th random number And all the random numbers have to be different */ using System; namespace Lottery { class Test { static void Main() { Console.Write("Welcome To Lottery, would you like to play? (yes/no) "); string answer = Console.ReadLine(); if (answer == "yes") { Console.WriteLine("Selecting Numbers at Random..."); Random rand = new Random(); int [] number; number = new int[6]; for( int i = 0; i < 7; i++ ) { number[i] = rand.Next(1, 49); } Console.WriteLine("Numbers have been selected!"); } else { Console.WriteLine("Thanks Anyways!"); Console.ReadLine(); } } } }
I am trying to check if any of the numbers randomly generated are duplicates and then replace them if they are. However, i have been unableto accomplish this, so any help would be appreciated.
If you have any suggestions on how to improve on my code that would be very helpfull.
Thank You
- Joel




Reply With Quote