A programmer is developing a new stock control program for a shop owner to produce sales reports.
- (a)A text file Sales.txt stores strings representing the number of items sold. The file contains 52 lines, each representing the number of items sold in each week of the year. For example: File line number File data 1 "350" 2 "502" 3 "434" . . 49 "492" 50 "872" 51 "772" 52 "201" The example shows that 502 items were sold in week 2. The owner requires a module to output all week numbers where the number of items sold is greater than 500. Describe an algorithm that produces the required module. Do not include pseudocode statements in your answer.[5]
- (b)Once the program has been completed, it is tested using the walkthrough method. Describe the walkthrough method and explain how it can be used to identify errors.[3]
Mark scheme
Marking points from the official mark scheme (May/June 2025). The mark or mark type is shown in brackets.
- [5] MP1 Open the file (Sales.txt) in read mode and subsequently close
- MP2 Read a line (from the text file)
- MP3 Convert the line read (string) to a number
- MP4 If the number is greater than 500 and then output week number
- MP5 Increment week number (must have been Initialised ...)
- MP6 Repeat from step 2 for 52 times // Repeat from step 2 until end of file
- Max 5
- [3] MP1 Going through the program a line / statement at a time // doing a dry run // single-stepping (at run-time with an IDE) // Peer testing/review is carried out
- MP2 Creating a trace table
- MP3 Draw up test data // draw up list of inputs with expected output // boundary, normal, abnormal data is used
- MP4 Errors will be indicated when a variable / output gives an unexpected value
- MP5 Faults in the logic of the program can be detected // Errors may be indicated by an unexpected path through the program
- Max 3
Write your answer and get it marked
On Oracle Prep you can write or photograph your own answer and have it marked by AI against this mark scheme, with feedback on what you missed.
Sign up free →