1. Engineering
  2. Computer Science
  3. the teacher has read an article suggesting that human brains...

Question: the teacher has read an article suggesting that human brains...

Question details

The teacher has read an article suggesting that human brains can often make sense of misspelt or jumbled words. She wishes to follow this up and see if her pupils can make sense of words in which certain characters have been replaced by stars (asterisks).

She requires a when[space]key_pressed script which will take a word from the user and a character from the user and display the word with each occurrence of the character replaced by a star. So, for example, if the user enters the word 'elephant' and the character 'e' then '*l*phant' is displayed.

One way (there are others) to think about creating such a new word for display is to work through the letters in the original word from first to last, creating a new word incrementally. This might be visualised as in the following example.

tm111_tma02_18j_f02.eps.jpg

Figure 2

a.Create and write down an algorithm to solve this problem. You might like to use the idea above, or an alternative of your own.

(10 marks)

b.Create a when[space]key_pressed script to implement your algorithm.

Take a screenshot of your script and paste it into your solution document.

(11 marks)

c.Copy the following table into your solution document and add to it two tests you would perform to check whether the completed script fulfils the specification. (Several tests might be appropriate, but you are only required to add two.)

Test number Test purpose Inputs Expected results
Word Character New word displayed
1 No occurrence of character in word elephant c elephant
2
3

3

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution