Skip to main content
A-LevelComputer ScienceFurther programming9618/21 · Oct/Nov 2024 · Q69 Marks

A factory produces food items. The items must be used within a certain number of days after their production date. The number of days is known as the shelf life. It is different for each type of item but is always a whole number in the range 1 to 21 (inclusive). The latest date that an item can be used is called the 'use-by' date. A program is needed to produce labels which show the 'use-by' date. Part of the program is a function GetDate() which will: • take two parameters: a production date and a value representing the shelf life • return the corresponding ‘use-by' date. The program contains a global 1D array DaysInMonth of type integer which stores the number of days in each month (index 1 is January): Index | Value ---|--- 1 | 31 2 | 28 3 | 31 4 | 30 11 | 30 12 | 31 Note: Leap years are not considered

  1. (a)An algorithm uses the array DaysInMonth to calculate a 'use-by' date. An alternative design would involve the use of multiple selection statements. An array-based technique is often used when there is a large number of different values to check and where no pattern exists. One advantage of using an array-based technique is the speed of execution compared to the use of multiple selection statements. Give two other advantages of using an array for this type of operation rather than a solution based on multiple selection statements. 1 2[2]
  2. (b)Complete the pseudocode for the function GetDate(). Date functions from the insert should be used in your solution. FUNCTION GetDate(ProductionDate : DATE, ShelfLife : INTEGER) RETURNS DATE ENDFUNCTION[7]

Mark scheme

Marking points from the official mark scheme (Oct/Nov 2024). The mark or mark type is shown in brackets.

  1. [1] (a) Fewer lines of code are needed
  2. [1] (a) The program is simpler/ less complex // Program is easier to design / code / maintain / modify / test / debug
  3. [1] (a) Direct access to days in a month / data (using month number as index) // Can use index / month to (directly) access days in month / data
  4. [1] (b) Declare three variables of TYPE INTEGER to store DD, MM and YY
  5. [1] (b) Correct use of date functions from Insert to extract three integer values representing DD, MM and YY and use/assign to a variable
  6. [1] (b) Add parameter ShelfLife to DD and use / assign result to a variable
  7. [1] (b) Extract LastDay from DaysInMonth using MM as Index
  8. [1] (b) Test for new DD after end of month / DaysInMonth[MM] ... and if DD > DaysInMonth[MM]: MM is incremented by 1 and DD is set to DD – DaysInMonth[MM]
  9. [1] (b) If MM = 13 / MM > 12 then increment YY and set MM to 1
  10. [1] (b) Use of SETDATE to assign value to NewDate, NewDate must be delared as a type DATE
  11. [1] (b) Return date
  12. FUNCTION GetDate(ProductionDate : DATE, ShelfLife : INTEGER) RETURNS DATE
  13. DECLARE NewDate: DATE
  14. DECLARE DD, MM, YY, LastDay : INTEGER
  15. DD ← DAY(ProductionDate)
  16. MM ← MONTH(ProductionDate)
  17. YY ← YEAR(ProductionDate)
  18. DD ← DD + ShelfLife
  19. LastDay ← DaysInMonth[MM]
  20. IF DD > LastDay THEN
  21. MM ← MM + 1
  22. DD ← DD – LastDay
  23. IF MM = 13 THEN
  24. MM ← 1
  25. YY ← YY + 1
  26. ENDIF
  27. ENDIF
  28. NewDate ← SETDATE(DD, MM, YY)
  29. RETURN NewDate
  30. ENDFUNCTION

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 →

About this question

Topic
Further programming, A-Level Computer Science (syllabus 9618). Structured question, 9 marks.
Source
A-Level Computer Science, Oct/Nov 2024 Paper 2 Variant 1, question 6.

Questions and mark schemes are from past examination papers and remain the copyright of the exam board. How Oracle Prep builds its content

Related Computer Science questions

© 2026 Oracle Prep