Question 13
AQA Computer Science June 2023 Paper 1C (8525/1C)GCSE6 marks
On the specification
- 3.2 Programming
Question text
13 box A programmer is writing a game. The game uses a 3 x 3 grid containing nine squares. Figure 14 A B C 1 2 3 X In the game, a square on the grid is referred to by a letter and a number. For example, square C3 in Figure 14 contains an X. Figure 15 shows part of a VB.NET program that checks the grid reference entered by a player. The grid reference is valid if: • there are exactly two characters • the first character entered is A, B or C • the second character entered is 1, 2 or 3. Figure 15 Dim check As Boolean = False While check = False Dim square As String = "" While square.Length <> 2 Console.Write("Enter grid reference (eg C2): ") square = Console.ReadLine() square = square.ToUpper() End While The VB.NET function ToUpper()converts letters into uppercase, eg b1 would be converted to B1 Extend the program from Figure 15 so it completes the other checks needed to make sure a valid grid reference is entered. Your extended program must: • use the variable check • repeat the following steps until a valid grid reference is entered: o get the user to enter a grid reference o output an appropriate message if the grid reference entered is not valid. You should use meaningful variable name(s) and VB.NET syntax in your answer. The answer grid contains vertical lines to help you indent your code. [6 marks] Dim check As Integer = False While check = False Dim square As String = "" While square.Length <> 2 Console.Write("Enter grid reference (eg C2): ") square = Console.ReadLine() square = square.ToUpper() End While End While