A procedure CountVowels () will: • be called with a string containing alphanumeric characters as its parameter • count and output the number of occurrences of each vowel (a, e, i, o, u) in the string • count and output the number of occurrences of the other alphabetic characters (as a single total). The string may contain both upper and lower case characters. Each count value will be stored in a unique element of a global 1D array CharCount of type INTEGER. The array will contain six elements. Write pseudocode for the procedure CountVowels().
- Write pseudocode for the procedure CountVowels().[8]
Mark scheme
Marking points from the official mark scheme (May/June 2021). The mark or mark type is shown in brackets.
- [1] PROCEDURE CountVowels(ThisString : STRING)
- [1] DECLARE Index : INTEGER
- [1] DECLARE ThisChar : CHAR
- [1] FOR Index ← 1 to 6
- [1] CharCount[Index] ← 0 //initialise elements
- [1] NEXT Index
- [1] Index ← 1
- [1] FOR Index ← 1 TO LENGTH(ThisString)
- [1] ThisChar ← LCASE(MID(ThisString, Index, 1))
- [1] CASE OF ThisChar
- [1] 'a' : CharCount [1] ← CharCount [1] + 1
- [1] 'e' : CharCount [2] ← CharCount [2] + 1
- [1] 'i' : CharCount [3] ← CharCount [3] + 1
- [1] 'o' : CharCount [4] ← CharCount [4] + 1
- [1] 'u' : CharCount [5] ← CharCount [5] + 1
- [1] 'a' TO 'z': CharCount (6) ← CharCount [6] + 1
- [1] ENDCASE
- [1] NEXT Index
- [1] FOR Index ← 1 to 6
- [1] OUTPUT CharCount [Index] //output results
- [1] NEXT Index
- [1] ENDPROCEDURE
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 →