A local restaurant kept a record of the number of customers who visited the restaurant per day during the past year - NSC Information Technology - Question 4 - 2018 - Paper 1
Question 4
A local restaurant kept a record of the number of customers who visited the restaurant per day during the past year.
Do the following:
- Open the incomplete progra... show full transcript
Worked Solution & Example Answer:A local restaurant kept a record of the number of customers who visited the restaurant per day during the past year - NSC Information Technology - Question 4 - 2018 - Paper 1
Step 1
4.1 - Populate Customer array
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
To populate the customer array, follow these steps:
Read the Month from Combo Box:
Extract the selected month from the combo box. This indicates which month’s data you are populating.
Initialize Counter:
Create a counter variable counter to 0 to keep track of the number of days in that month.
Loop Through the Array:
Use a loop to read the data for the selected month from arrTempCustomers.
Test for Selected Month:
For each day in the array, check if it corresponds to the selected month.
Increment Counter:
If a match is found, increment the counter.
Find Position of Customers:
Use the index to retrieve the number of customers for each day from arrTempCustomers and store it in arrCustomers.
Conversion to Integer:
Convert the data from arrTempCustomers to an integer and store it in the respective position of arrCustomers.
Display a Success Message:
After completing the population of the array, display a message indicating successful updates.
Step 2
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
To display the customer data, follow these steps:
Extract Day of Week:
Read the selected index from the combo box (add 1 to the index for correct referencing).
Initialize Output String:
Create an output string variable to compile the display information.
Loop Through Days of the Week:
Use a loop to iterate through the number of days in the selected month and populate the output string.
Count Days in the Week:
Count the number of days until the last day of the month based on previous calculations.
Construct the Output:
For each day, format the string to include the number of customers, using brackets to display the respective values from arrCustomers.
Display the Output Line:
After the loop completes, compile the output string and display it in the user interface.