Button [4.1 - Codes]
Write code to do the following:
Remove all the special characters from each code in the array to create a new code - NSC Information Technology - Question 4 - 2023 - Paper 1
Question 4
Button [4.1 - Codes]
Write code to do the following:
Remove all the special characters from each code in the array to create a new code. Count how many special cha... show full transcript
Worked Solution & Example Answer:Button [4.1 - Codes]
Write code to do the following:
Remove all the special characters from each code in the array to create a new code - NSC Information Technology - Question 4 - 2023 - Paper 1
Step 1
Remove all the special characters
96%
114 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
Start by initializing an empty string sLine to store the new code without special characters. Loop through the arrCodes array by index. For each code, loop through its characters, checking if each character is either a letter (a-z, A-Z) or a digit (0-9). If a character passes the test, concatenate it to sLine.
After processing the code, determine the length of the original code and subtract the length of sLine from it to find the number of special characters removed. Finally, display the new code and the count in the format <New code>(number of special characters deleted).
Step 2
Place extra IT periods
99%
104 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
Initialize a counter for the week (Monday to Thursday). Loop through the days, checking if each cell in the arrTimeTable for the current day is blank. If it is, assign 'IT' to the first available period. Increment the counter each time an 'IT' is placed.