Question 3

AQA Computer Science June 2024 Paper 1C (8525/1C)GCSE6 marks

On the specification

3.1
3.2 Programming
3.2
3.2 Programming
3.3
3.2 Programming
Question text

3 Figure 3 shows an incomplete VB.NET program for a number guessing game. box • Line numbers are included but are not part of the program. Figure 3 1 Dim rGen As New Random() 2 Dim randomNumber As Integer 3 4 Console.WriteLine("Enter a number") 5 Dim userNumber As Integer = Console.ReadLine() 6 While userNumber < 1 Or userNumber > 100 7 Console.WriteLine("Invalid number") 8 userNumber = Console.ReadLine() 9 End While 10 Console.WriteLine("Valid number entered") 11 If randomNumber = userNumber Then 12 Console.WriteLine("Number guessed correctly") 13 End If 3.1 The program should generate a random number between 1 and 100 (including 1 and 100). This will be the number the user has to guess. Write the VB.NET code that should be used on line 3 in Figure 3 to: • generate a random number between 1 and 100 inclusive • assign this number to the appropriate variable from the program. You must use rGen.Next(a, b) in your VB.NET code. rGen.Next(a, b) generates a random integer in the range a to b starting at a but finishing one before b [2 marks] 3.2 Complete the test plan in Table 1 to test the validation of userNumber in the box program in Figure 3. [2 marks] Table 1 Test number Test type Test data Expected result 1 Erroneous 150 2 Boundary 3 Normal Valid number entered 3.3 In an earlier version of the program in Figure 3, line 6 contained one syntax error and one logic error: Whil userNumber < 1 Or userNumber >= 100 Complete the table to describe the errors in the program on line 6. [2 marks] Error type Description Syntax error Logic error