Question 7

OCR Computer Science June 2016 Paper 1AS6 marks

On the specification

2.2 Problem solving and programming1.4 Data types, data structures and algorithms
Question text

7 A DIY store has an offer: ‘Spend £20 or more on decorating products and get 10% off all gardening products.’ When items are scanned in at the checkout they are stored in a 2-dimensional array called purchases, which stores the item name, category and price. A receipt with the appropriate discounts deducted is then produced. Examples of the array and corresponding receipt are shown in Fig. 2 and Fig. 3. Matt Pink Paint Decorating 6.99 Matt Pink Paint £6.99 Floral Wallpaper Decorating 7.99 Floral Wallpaper £7.99 Magnolia Gloss Paint £5.49 Magnolia Gloss Paint Decorating 5.49 Weed Killer £2.99 Weed Killer Gardening 2.99 -£0.30 discount Picture Frame £8.99 Picture Frame Decorating 8.99 Plug Socket £6.99 Doorbell £15.99 Plug Socket Electrics 6.99 Matt White Paint £4.99 Doorbell Electrics 15.99 Tiles £19.99 Grass Seed £1.99 Matt White Paint Decorating 4.99 -£0.20 discount Lawn Mower £129.99 Tiles Decorating 19.99 -£13.00 discount Grass Seed Gardening 1.99 ---------------- TOTAL: £198.89 Lawn Mower Gardening 129.99 Fig. 2 Fig. 3 Write an algorithm in pseudocode, using the array purchases, to: • determine which items are given a discount • calculate the total price to pay • present this information on a receipt in the format shown in Fig. 3. [6]