Photo AI
Question 4
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
Step 1
Answer
Extract Selected Mall: Use the text of the selected radio button to determine the specific mall to refer to.
Set Up Text File: Assign the appropriate text file corresponding to the chosen mall, ensuring it is set to read correctly.
Initialize Variables: Reset the row counter to 0 to prepare for processing the text file.
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.
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.
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.
Display Results: Output the formatted string that includes the levels and corresponding shop counts. Ensure it is right-justified effectively.
Close File: Make sure to properly close the file after all processing is completed.
Step 2
Answer
Input Shop Type: Prompt the user to enter the type of shop they wish to count.
Validate Input: Confirm that the entered shop type is valid, returning feedback for any incorrect entries.
Initialize Counters: Set up a counter for the number of shops per level, resetting it as necessary.
Loop Through Levels: For each level in arrShopTypes, loop through the string value to count occurrences of the selected shop type.
Count Shops: Increment the counter each time the specified shop type is found on the given level.
Display Results: Output the total counts for each level with the designated shop type clearly indicated.
Report Improved Results
Recommend to friends
Students Supported
Questions answered