The trees at the nursery are categorised using the types Citrus, Deciduous, Nut, and Tropical - NSC Information Technology - Question 4 - 2019 - Paper 1
Question 4
The trees at the nursery are categorised using the types Citrus, Deciduous, Nut, and Tropical.
Do the following:
Open the incomplete program in the Question 4 fold... show full transcript
Worked Solution & Example Answer:The trees at the nursery are categorised using the types Citrus, Deciduous, Nut, and Tropical - NSC Information Technology - Question 4 - 2019 - Paper 1
Step 1
Button [4.1 - Separate by type]
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
Initialize a loop from 1 to the number of tree types (iTypes).
Set the initial column to 0.
Create an inner loop to loop through the elements in the arrList from 1 to 24.
For each element, check if the last character of arrList[index] corresponds to the first character of arrTypes[row].
Increment the column value in arrTrees[row, column] with the value of arrList[index].
Enable buttons btnQ4_2 and btnQ4_3 after processing all elements.
Step 2
Button [4.2 - Display]
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
Loop through each row from 1 to iTypes.
Create a string variable sLine for displaying tree types. Append the corresponding trees from arrTrees[row, col].
Utilize a nested loop to concatenate all relevant tree names into sLine.
Display the final sLine in the output area.
Step 3
Button [4.3 - Sort alphabetically]
96%
101 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
Start with a loop from 1 to the number of tree types (iTypes).
Within each iteration, loop through arrTrees to delete the last two characters of each tree name.
Reassign each adjusted value to ensure proper sorting.
Use a sorting algorithm to arrange the trees alphabetically by type.
Finally, execute the display code in btnQ4_2 to show the updated list.