Members of a litter picking group complete a litter pick every month. Members' names are stored in one-dimensional (1D) array PickerName[] Each member stores the weight of the litter they have picked in another one-dimensional (1D) array PickedWeight[] The weights are in kilograms with one decimal place, for example 8.4 The position of each member's data in the two arrays is the same. For example, the member stored at index 10 in PickerName[] and at index 10 in PickedWeight[] is the same. Every month, there is a small prize awarded to the members of the group who have the two heaviest weights. Certificates are awarded to all members with a pick weight of over three kilograms. Write a program that meets the following requirements: • allows the weight of members' picks to be input and validated • sorts the arrays PickedWeight[] and PickerName[] in descending order of weight • outputs the member names and the pick weights of the members with the two heaviest picks and identifies them as "Best in Group" and "Second best in Group" • stores the names of all the members who will receive a certificate in the array PickerCertificate[] • outputs a message stating the number of certificates to be printed. You must use pseudocode or program code and add comments to explain how your code works. You do not need to declare any arrays or variables; you may assume that this has already been done. All inputs and outputs must contain suitable messages. You do not need to initialise the data in the array PickerName[]
Mark scheme
Marking points from the official mark scheme (Oct/Nov 2024). The mark or mark type is shown in brackets.
- AO2 (maximum 9 marks)
- AO3 (maximum 6 marks)
- Data Structures required names shown underlined must match those given in the scenario
- 2D Array or list PickerName[],PickedWeight[],PickerCertificate[]
- Variables
- Requirements (techniques)
- R1 Input and validate the weights (input and iteration)
- R2 sort the PickerName[],and PickedWeight[] arrays in descending order of weight (nested iteration and sorting)
- R3 Output top two members and the weights. Storing the members names who will receive a certificate and outputting the number of certificates (iteration, selection, assignment, counting and output with appropriate messages)
- Example 15-mark answer in pseudocode:
- CONSTANT GroupSize = 200 // setting the number of members in the club
- DECLARE Position : Array[1:2} OF STRING
- Position[1] ← "Best in Group"
- Position[2] ← "Second best in Group"
- FOR Index ← 1 TO GroupSize
- REPEAT
- PRINT "Please enter the weight for ", PickerName[Index],
- INPUT PickedWeight[Index]
- UNTIL PickedWeight[Index] > 0 AND PickedWeight[Index] < 15
- NEXT Index
- Last ← GroupSize
- REPEAT
- Swap ← FALSE
- FOR Index ← 1 TO GroupSize -1
- IF PickedWeight[Index] < PickedWeight[Index + 1]
- THEN
- TempWeight ← PickedWeight[Index]
- PickedWeight[Index] ← PickedWeight[Index + 1]
- PickedWeight [Index + 1] ← TempWeight
- TempName ← PickerName[Index]
- PickerName[Index] ← PickerName[Index + 1]
- PickerName[Index + 1] ← TempName
- Swap ← TRUE
- ENDIF
- NEXT Index
- Last ← Last - 1
- UNTIL NOT Swap or Last = 1
- FOR Index ← 1 TO 2
- OUTPUT Position[Index], PickerName[Index], " with a weight of ", PickedWeight[Index]
- NEXT Index
- Index ← 1
- Count ← 0
- WHILE PickedWeight[Index] > 3 DO // count number of certificates required and store names
- Count ← Count + 1
- PickerCertificate[Count] ← PickerName[Index]
- Index ← Index + 1
- ENDWHILE
- OUTPUT "Number of certificates to be printed is ", Count
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 →