Photo AI

The trees at the nursery are categorised using the types Citrus, Deciduous, Nut, and Tropical - NSC Information Technology - Question 4 - 2019 - Paper 1

Question icon

Question 4

The-trees-at-the-nursery-are-categorised-using-the-types-Citrus,-Deciduous,-Nut,-and-Tropical-NSC Information Technology-Question 4-2019-Paper 1.png

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

Answer

  1. Initialize a loop from 1 to the number of tree types (iTypes).
  2. Set the initial column to 0.
  3. Create an inner loop to loop through the elements in the arrList from 1 to 24.
  4. For each element, check if the last character of arrList[index] corresponds to the first character of arrTypes[row].
  5. Increment the column value in arrTrees[row, column] with the value of arrList[index].
  6. Enable buttons btnQ4_2 and btnQ4_3 after processing all elements.

Step 2

Button [4.2 - Display]

99%

104 rated

Answer

  1. Loop through each row from 1 to iTypes.
  2. Create a string variable sLine for displaying tree types. Append the corresponding trees from arrTrees[row, col].
  3. Utilize a nested loop to concatenate all relevant tree names into sLine.
  4. Display the final sLine in the output area.

Step 3

Button [4.3 - Sort alphabetically]

96%

101 rated

Answer

  1. Start with a loop from 1 to the number of tree types (iTypes).
  2. Within each iteration, loop through arrTrees to delete the last two characters of each tree name.
  3. Reassign each adjusted value to ensure proper sorting.
  4. Use a sorting algorithm to arrange the trees alphabetically by type.
  5. Finally, execute the display code in btnQ4_2 to show the updated list.

Join the NSC students using SimpleStudy...

97% of Students

Report Improved Results

98% of Students

Recommend to friends

100,000+

Students Supported

1 Million+

Questions answered

;