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
Practise AQA GCSE Computer Science Random number generation in a programming language with exam-style questions for GCSE Computer Science. 8 questions, matched to the AQA GCSE Computer Science (8525) specification and written in Paper 1 and Paper 2 style. Every question includes a full worked solution and mark scheme, so you can see where marks are awarded rather than just whether you got the answer right.