Question 2
OCR Computer Science June 2022 Algorithms and problem solving (H046-02)AS19 marks
On the specification
- (a)(i)
- 2.2 Problem solving and programming
- (a)(ii)
- 2.1 Elements of computational thinking
- (a)(iii)
- 2.2 Problem solving and programming
- (b)
- 2.2 Problem solving and programming
Question text
2 Logan is writing a program for his customers to be able to buy his gym equipment. In the program, once a customer has selected the items they want to buy, a procedure, checkDetails, will be called. This procedure will check that the customer has input their telephone number and also check that it is at least 11 characters long. (a) Logan has written two possible versions of the procedure that could be used to achieve this. Version One: procedure checkDetails() telephoneNo = input("Enter telephone number") while (telephoneNo == "") or (telephoneNo.length < 11) print("Error, please try again") telephoneNo = input("Enter telephone number") endwhile endprocedure Version Two: procedure checkDetails() telephoneNo = input("Enter telephone number") if (telephoneNo == "") or (telephoneNo.length < 11) then print("Error, please try again") telephoneNo = input("Enter telephone number") endif endprocedure (i) Explain why version one is more effective than version two at making sure that the telephone number entered is at least 11 characters long. [4] (ii) As well as the procedure checkDetails, Logan would like to use additional procedures to expand his program. The program will be expanded to: • allow customers to be able to register an account by setting up a username and password • allow registered users to be able to log-in with their registration details • allow customers, once logged in, to be able to add items that are in stock to their online shopping basket. State two other procedures that Logan could write to meet these requirements, and for each one, state a suitable name and purpose. Procedure 1: Procedure Name: Purpose: Procedure 2: Procedure Name: Purpose: [4] (iii) When setting up the additional procedures in his program, Logan will use a mixture of parameter passing by reference and by value. State the difference between parameter passing by reference and parameter passing by value. [2] (b)* Logan will work in a team with five other programmers and together they will create the programming code for the program. Discuss how modularity can be used to allow the team of programmers to work effectively together on the same program at the same time. [9]