Photo AI

Three new malls have been built recently - NSC Information Technology - Question 4 - 2021 - Paper 1

Question icon

Question 4

Three-new-malls-have-been-built-recently-NSC Information Technology-Question 4-2021-Paper 1.png

Three new malls have been built recently. Each mall has a ground floor that has shops to showcase the types of shops on the different levels at the mall. For example... show full transcript

Worked Solution & Example Answer:Three new malls have been built recently - NSC Information Technology - Question 4 - 2021 - Paper 1

Step 1

Button [4.1 - Populate and display array]

96%

114 rated

Answer

  1. Extract Selected Mall: Use the text of the selected radio button to determine the specific mall to refer to.

  2. Set Up Text File: Assign the appropriate text file corresponding to the chosen mall, ensuring it is set to read correctly.

  3. Initialize Variables: Reset the row counter to 0 to prepare for processing the text file.

  4. Read Line from Text File: Loop through the lines in the text file, reading each line into an array that matches the specific position for the level.

  5. Store Shops in Array: Store the data of shops in the correct positions of the array, ensuring it reflects the structure of the input file.

  6. Compile Output String: Construct the output string, ensuring the appropriate format is maintained, which includes line numbering, added spaces to meet the length of 25 characters, and the display of shop names.

  7. Display Results: Output the formatted string that includes the levels and corresponding shop counts. Ensure it is right-justified effectively.

  8. Close File: Make sure to properly close the file after all processing is completed.

Step 2

Button [4.2 - Count type of shop per level]

99%

104 rated

Answer

  1. Input Shop Type: Prompt the user to enter the type of shop they wish to count.

  2. Validate Input: Confirm that the entered shop type is valid, returning feedback for any incorrect entries.

  3. Initialize Counters: Set up a counter for the number of shops per level, resetting it as necessary.

  4. Loop Through Levels: For each level in arrShopTypes, loop through the string value to count occurrences of the selected shop type.

  5. Count Shops: Increment the counter each time the specified shop type is found on the given level.

  6. Display Results: Output the total counts for each level with the designated shop type clearly indicated.

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

;