A string represents a series of whole numbers, separated by commas. For example: "12,13,451,22" Assume that: • the comma character ',' is used as a separator • the string contains only the characters '0' to '9' and the comma character ','. A procedure Parse will: • take the string as a parameter • extract each number in turn • calculate the total value and average value of all the numbers • output the total and average values with a suitable message.
- (a)Write pseudocode for the procedure. PROCEDURE Parse(InString : STRING) ENDPROCEDURE[7]
Mark scheme
Marking points from the official mark scheme (May/June 2022). The mark or mark type is shown in brackets.
- [7] Marks as follows:
- 1 Declare and initialise Count, Total and NumString
- 2 Loop for number of characters in InString
- 3 Extract a character and test for comma in a loop
- 4 If comma, convert NumString to integer and update Total and Count
- 5 and reset NumString
- 6 Otherwise append character to NumString
- 7 Calculate average AND final output statement(s) outside the loop
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 →