A program simulates a lottery draw where a winning number is randomly chosen.
The program should generate a random number between 1 and 50 (including 1 and 50). This will represent the winning lottery ball number.
Write the VB.NET code that should be used on line 3 of the program below to:
You must use rand.Next(a, b) in your VB.NET code.
Note: rand.Next(a, b) generates a random integer starting at a up to, but not including, b.
1 Dim rand As New Random()
2 Dim winningBall As Integer
3
4 Console.WriteLine("Enter your lottery choice (1-50):")
5 Dim playerSelection As Integer = Console.ReadLine()
6 While playerSelection < 1 Or playerSelection > 50
7 Console.WriteLine("Invalid selection")
8 playerSelection = Console.ReadLine()
9 End While
10 Console.WriteLine("Selection accepted")
11 If winningBall = playerSelection Then
12 Console.WriteLine("You won the jackpot!")
13 End If
8 exam-style questions on AQA GCSE Computer Science Random number generation in a programming language. Each one has a worked solution and a mark scheme showing where the marks go.