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 4
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
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
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.
Display Heading - Print the table headers RegNum and Time In.
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
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
For the exit button functionality, the following steps must be implemented:
Extract registration number - Get the selected vehicle's registration number from cmbQ4.
Extract exit time - Read the exit time entered in edtQ4.
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'.
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.
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.
Calculate total cost - Compute the total cost using:
ext{Cost} = ext{Tariff} * ext{Ceil}igg(rac{ ext{TimeSpent}}{60}igg)
Output results - Display the registration number, entry time, exit time, time spent in hours and minutes, applicable tariff per hour, and total cost.