Question 4
AQA Computer Science June 2023 Paper 1C (8525/1C)GCSE4 marks
On the specification
- 4.1
- 3.1 Fundamentals of algorithms3.2 Programming
- 4.2
- 3.2 Programming
Question text
4 box Figure 3 shows a program written in VB.NET that calculates the area of a rectangle or the volume of a box from the user inputs. Figure 3 Function calculate(width As Integer, length As Integer, height As Integer) As Integer If height = -1 Then Return width * length Else Return width * length * height End If End Function Sub Main() Dim numOne, numTwo, numThree, answer As Integer Console.Write("Enter width: ") numOne = Console.ReadLine() Console.Write("Enter length: ") numTwo = Console.ReadLine() Console.Write("Enter height, -1 to ignore:") numThree = Console.ReadLine() answer = calculate(numOne, numTwo, numThree) If numThree = -1 Then Console.WriteLine($"Area {answer}") Else Console.WriteLine($"Volume {answer}") End If End Sub 4.1 Complete the trace table using the program in Figure 3. [3 marks] numOne numTwo numThree Final output 56 –1 10 4 0 35 10 4.2 Describe one way that the program in Figure 3 could be made more robust. box [1 mark]