2210/22/O/N/20 question 1: worked solution (October/November 2020, paper 22)
Show as plain textHide plain text
Cambridge O Level Computer Science 2210 · 8.1 Programming concepts Worked solution from the Programming Paper 2 Algorithms, Programming and Logic booklet, Part 1 of 3. Q4 2210/22/O/N/20 original Q1 Structured · 20 marks Worked solution (a)(i) Array: SysPrice (or SysStore) [1] Purpose: stores the price of each system, or the system parts bought [1] (a)(ii) Variable: TotalPrice [1] Purpose: stores the running total price of the system being built [1] (a)(iii) Constant: Offer5 [1] Purpose: stores the discount rate for one extra option [1] (b) Give two different points, or one point and an expansion. Real numbers can be used directly in calculations , which the price needs [1] They store decimal places , so prices with cents are kept, which a string cannot do [1] (c) Ask for each item, check the code, find its price and add everything up. Shown for the case, RAM and hard disk drive. OUTPUT "Which type of Case would you like? Input the Item Code" ComponentFlag ← False WHILE ComponentFlag = False DO INPUT CaseCode Count ← 0 WHILE Count < 2 DO IF CaseCode = ComponentCode[Count] THEN CaseIndex ← Count ComponentFlag ← True Count ← 2 ENDIF Count ← Count + 1 ENDWHILE IF ComponentFlag = False THEN OUTPUT "Your Item Code does not exist, please try again" ENDIF ENDWHILE OUTPUT "Which type of RAM would you like? Input the Item Code" ComponentFlag ← False WHILE ComponentFlag = False DO INPUT RAMCode Count ← 2 WHILE Count < 5 DO IF RAMCode = ComponentCode[Count] THEN RAMIndex ← Count ComponentFlag ← True Count ← 5 ENDIF Count ← Count + 1 ENDWHILE IF ComponentFlag = False THEN OUTPUT "Your Item Code does not exist, please try again" ENDIF ENDWHILE OUTPUT "Which type of Hard Disk Drive would you like? Input the Item Code" ComponentFlag ← False WHILE ComponentFlag = False DO INPUT HDDCode Count ← 5 WHILE Count < 8 DO IF HDDCode = ComponentCode[Count] THEN HDDIndex ← Count ComponentFlag ← True Count ← 8 ENDIF Count ← Count + 1 ENDWHILE IF ComponentFlag = False THEN OUTPUT "Your Item Code does not exist, please try again" ENDIF ENDWHILE TotalPrice ← 200 + ComponentPrice[CaseIndex] + ComponentPrice[RAMIndex] + ComponentPrice[HDDIndex] OUTPUT "Your computer is ", Description[CaseIndex], ", ", Description[RAMIndex], " and ", Description[HDDIndex] OUTPUT "The total price of your computer is $", TotalPrice Any six of these points score one each. Inputs for all three items (case, RAM and drive), each with a prompt [1] An attempt at validation of the input [1] One complete validation with an error message [1] The price of each chosen item found correctly [1] The prices added together with the basic cost of the computer [1] The chosen items stored, and the items and total price output with a message [1] Other correct algorithms score too. (d) Explain each step. Any four of these. How the number of extra parts is stored [1] How the extra parts are counted as they are added [1] How the program decides if there is one extra part or more than one [1] Using the correct percentage discount, then working out the money saved and the new price, and outputting them [1] (e) Any two of these. Ask the buyer at the start (or after the first computer) how many computers they want, with a prompt and input [1] Put a loop around the program, and add new storage for each computer ordered [1] KEY IDEA Name data items that match the task, and explain or write each step in the order the program runs. TOTAL 20 marks Official mark scheme VIDEO ▶ Whole paper Video solution of the whole paper · by Quixotic Academy. Tap the picture to open it on YouTube.