Photo AI

The Parking Group has requested your assistance for the implementation of the calculation of cost when vehicles exit a parking area - NSC Information Technology - Question 4 - 2022 - Paper 1

Question icon

Question 4

The-Parking-Group-has-requested-your-assistance-for-the-implementation-of-the-calculation-of-cost-when-vehicles-exit-a-parking-area-NSC Information Technology-Question 4-2022-Paper 1.png

The Parking Group has requested your assistance for the implementation of the calculation of cost when vehicles exit a parking area. Do the following: - Open the i... show full transcript

Worked Solution & Example Answer:The Parking Group has requested your assistance for the implementation of the calculation of cost when vehicles exit a parking area - NSC Information Technology - Question 4 - 2022 - Paper 1

Step 1

Button [4.1 - Display]

96%

114 rated

Answer

To implement the logic for the display button, first, we need to create a loop that runs from 1 to the number of elements in the arrRegNumbers array. This iterates through the registration numbers and their respective entry times.

  1. Display Heading - Print the table headers RegNum and Time In.
  2. Loop through elements - For each index k, display arrRegNumbers[k] as a string along with the corresponding arrEntryTimes[k] in a neat column format. This will give a clear tabular view of all vehicles that have entered the parking area.

Step 2

Button [4.2 - Exit parking area]

99%

104 rated

Answer

For the exit button functionality, the following steps must be implemented:

  1. Extract registration number - Get the selected vehicle's registration number from cmbQ4.
  2. Extract exit time - Read the exit time entered in edtQ4.
  3. Validate exit time - Compare the exit time to the entry time in the arrEntryTimes corresponding to the selected registration number. If the exit time is earlier, display 'Invalid exit time'.
  4. Calculate time spent - Convert both entry and exit times to minutes and calculate the difference to find the total time spent in the parking area.
  5. Determine tariff - Use the following conditions to determine the applicable tariff:
    • If time spent <= 30 minutes, tariff is Free.
    • If 31 <= time spent <= 120 minutes, tariff is R50.00 per hour.
    • If 120 < time spent <= 240 minutes, tariff is R40.00 per hour.
    • If time spent > 240 minutes, tariff is R30.00 per hour.
  6. Calculate total cost - Compute the total cost using: ext{Cost} = ext{Tariff} * ext{Ceil}igg( rac{ ext{TimeSpent}}{60}igg)
  7. Output results - Display the registration number, entry time, exit time, time spent in hours and minutes, applicable tariff per hour, and total cost.

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

;