A procedure, FormatName(): • is called with a string containing words and spaces as its parameter. In this context, a word is any sequence of characters that does not contain a space character. • creates a new formatted string from this string with the following requirements: 1. Any leading spaces removed (spaces before the first word). 2. Any trailing spaces removed (spaces after the last word). 3. Any multiple spaces between words converted to a single space. 4. All characters converted to lower case. The FormatName() procedure has been written in a programming language and is to be tested using the black-box method.
- (a)Give a test string that could be used to show that all four formatting requirements have been applied correctly. Use the symbol 'V' to represent a space character.[3]
- (b)The FormatName() procedure should assign a value to the global variable FString. There is a fault in the program, which means that the assignment does not always take place. Explain two ways of exposing the fault.[2]
Mark scheme
Marking points from the official mark scheme (May/June 2021). The mark or mark type is shown in brackets.
- [1] (a) At least one leading space (before the first word)
- [1] (a) at least one trailing space (after the last word)
- [1] (a) at least one instance of multiple spaces between words
- [1] (a) At least one upper case character
- [1] (b) Dry run / produce a trace table / walk through the code
- [1] (b) Add output statements to allow the code to be tracked
- [1] (b) Insert a Breakpoint into the program // use single-stepping to execute instructions // monitor variables using a watch window
- [1] (b) Try different test values to see which ones fail
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 →