Question 3

AQA Computer Science June 2022 Paper 1A (8525/1A)GCSE2 marks

On the specification

3.1
3.2 Programming
3.2
3.2 Programming
Question text

3 box Figure 4 shows a C# program that calculates car park charges. The user inputs their car registration (eg MA19 GHJ) and the length of the stay. The program then outputs the charge. • Line numbers are included but are not part of the program. Figure 4 1 int charge = 0; 2 Console.Write("Enter your car registration: "); 3 string carReg = Console.ReadLine(); 4 while (carReg.Length > 8) { 5 string displayMessage = " is not valid"; 6 Console.Write(displayMessage); 7 carReg = Console.ReadLine(); 8 } 9 Console.Write("Enter your stay in hours: "); 10 int hours = Convert.ToInt32(Console.ReadLine()); 11 if (hours < 2) { 12 charge = 0; 13 } 14 else { 15 charge = hours * 2; 16 } 17 Console.WriteLine(charge); 3.1 Rewrite line 5 in Figure 4 to concatenate the car registration with the string " is not valid", and store the result in the variable displayMessage. Your answer must be written in C#. [1 mark] 3.2 The charge for parking for two or more hours is changed to include an additional £2 fee. Rewrite line 15 in Figure 4 to show this change. Your answer must be written in C#. [1 mark]