Photo AI
Question 3
Question 3: PROBLEM-SOLVING PROGRAMMING SCENARIO Information centres, referred to as 'terminals', have been set up at three different points along the routes in th... show full transcript
Step 1
Answer
To display the content of the two-dimensional array arrArtCodes
, follow these steps:
Set Up Column Headings: Begin with displaying the column headings that correspond to the directions (North, South, East, West).
Outer Loop for Rows: Use an outer loop to iterate over the terminals (Terminal 1, Terminal 2, Terminal 3).
Inner Loop for Columns: Within the outer loop, use an inner loop to go through each direction.
Fetch and Display Codes: During each iteration, fetch the corresponding activity code from the arrArtCodes
array based on the terminal and direction.
Output Formatting: Join the elements from the arrArtCodes
array into a single output line per terminal. Display each on a new line for clarity.
Display Neatly: Ensure outputs are formatted into neat columns for better readability.
Step 2
Answer
To display activities from a selected terminal and direction, implement the following steps:
Display Selected Terminal and Direction: Show the user the chosen terminal number and direction in the output area.
Retrieve Activity Code: Extract the activity codes from the arrCodes
by first selecting the terminal and its respective direction.
Loop Through Codes: Loop through the length of the extracted code to access each code in the arrCodes
array.
Comparison and Display: For every code compared with the arrCodes
, fetch the corresponding activity from arrActivities
and display it alongside its code.
Output Activities: Formulate a clear and concise output that lists the activities accessible from that terminal and direction.
Step 3
Answer
To access routes to a selected activity, follow these steps:
Extract Selected Index: Get the index of the selected activity from the combo box.
Initialize Counter: Start a counter at 0 to keep track of the number of access routes.
Display Heading: Show a heading indicating the following information will be related to the selected activity.
Outer Loop for Terminals: Create an outer loop to evaluate each terminal entry within arrArtCodes
.
Inner Loop for Directions: Use an inner loop for columns to check each direction whether the selected activity's code exists in the corresponding code within the array.
Display Valid Entries: If the selected activity is part of the terminal's direction codes, display the terminal number and direction, and increment the counter by 1.
Final Count Display: After looping through all entries, display the total routes available based on the counter.
Step 4
Answer
To handle maintenance codes for an activity, perform the following actions:
Select Activity from Combo Box: Begin by extracting the index of the selected activity for which maintenance is needed.
Outer Loop for Terminals: Implement an outer loop to process over rows for each terminal’s activity codes.
Check Conditions: Within the loop, verify if the selected activity's code exists in the two-dimensional array to identify relevant terminals.
Update Access Code: Remove the corresponding access code from the arrArtCodes
array for the selected activity, making it unavailable due to maintenance.
Display Notification: Output a message indicating that the access routes to the selected activity/facility are closed due to maintenance.
Refresh Display: Adjust the output area to show the updated version of the arrArtCodes
array reflecting the removed codes.
Report Improved Results
Recommend to friends
Students Supported
Questions answered