Photo AI

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 icon

Question 4

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.png

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

Answer

To populate the customer array, follow these steps:

  1. Read the Month from Combo Box:

    • Extract the selected month from the combo box. This indicates which month’s data you are populating.
  2. Initialize Counter:

    • Create a counter variable counter to 0 to keep track of the number of days in that month.
  3. Loop Through the Array:

    • Use a loop to read the data for the selected month from arrTempCustomers.
  4. Test for Selected Month:

    • For each day in the array, check if it corresponds to the selected month.
  5. Increment Counter:

    • If a match is found, increment the counter.
  6. Find Position of Customers:

    • Use the index to retrieve the number of customers for each day from arrTempCustomers and store it in arrCustomers.
  7. Conversion to Integer:

    • Convert the data from arrTempCustomers to an integer and store it in the respective position of arrCustomers.
  8. 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

Answer

To display the customer data, follow these steps:

  1. Extract Day of Week:

    • Read the selected index from the combo box (add 1 to the index for correct referencing).
  2. Initialize Output String:

    • Create an output string variable to compile the display information.
  3. 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.
  4. Count Days in the Week:

    • Count the number of days until the last day of the month based on previous calculations.
  5. Construct the Output:

    • For each day, format the string to include the number of customers, using brackets to display the respective values from arrCustomers.
  6. Display the Output Line:

    • After the loop completes, compile the output string and display it in the user interface.

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

;