SlideShare a Scribd company logo
1 of 33
Download to read offline
© Muzzammil Muttur – 2022 1
CIE O Level
November 2022 – Paper 2
Solutions for Pre-Release Material
Version 2.1
©Muzzammil Muttur – July 2022
Please feel free to distribute this document.
No modifications allowed to this document without prior permission.
Note: All modifications in new version are highlighted in green.
Thank you to email all your suggestions, comments and feedback.
Muzzammil Muttur
5 493 1972
Facebook Page: @mmuttur
learnatedutech@gmail.com
© Muzzammil Muttur – 2022 2
Pre Release Material
© Muzzammil Muttur – 2022 3
© Muzzammil Muttur – 2022 4
QUESTION BREAKDOWN
● Visitor car park has 20 spaces
● Car park spaces are numbered 1 to 20
● Booking can be made visitors up to 2 weeks in advance
● To make a booking: visitor must provide license number of car and customer name
● The next available parking space (beginning at space 1) is allocated and given data is stored
● System needs to record car park bookings
● Program work for a period of two weeks
SCENARIO
● person comes for visitor parking space booking
● user is shown a menu with three options: make a parking place booking, delete and reset all data
structures (arrays) or exit the system
● person provides car license number and name
● system checks if there are free spaces for that day
● if there are free spaces for required day, then give next free space (starting from number 1) to customer
and store data needed
ASSUMPTIONS:
● a parking space is booked for a whole day
● a customer books one parking slot at a time
● no document is checked for accessible parking space
© Muzzammil Muttur – 2022 5
Processing Required
© Muzzammil Muttur – 2022 6
TASK 1
 use arrays to store required data
 arrays to store car license numbers and names of visitors who have booked car parking spaces
 arrays must have enough spaces for a static period of two weeks
 a visitor can request a parking space for any day within the two-week period
 system must check that there are free spaces on the day requested
 visitor enter their name and car license number for making booking
 data will be stored in data structures (arrays)
 parking space will be given for next available space for the day requested
 if there are no free parking spaces for the day requested, the visitor is informed that booking
cannot be done
 visitor must be told the number of their parking space for that day
 at the end of the two-week period, all data is to be deleted and system must be ready for the next
two week period
TASK 2
 ask user if accessible space is needed
 answer to be recorded as Y/N
 if accessible space is to be given, then allocate the first free space (starting from
 if no accessible space is to be given, then give the first free space as from space 20 (general spaces)
and keep decrementing until parking space 6 is booked
© Muzzammil Muttur – 2022 7
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
© Muzzammil Muttur – 2022 8
TASK 3
 calculate statistics based on the array used to store parking space booking
 use a counter to access the array for the different days
 show the user a menu to choose between the different statistics that can be generated
 choice 1: display the number of accessible spaces used on a specific day (count number of elements
not set to “Free” for spaces 1 to 5)
 choice 2: display the number of general spaces used on a specific day (count number of elements not
set to “Free” for spaces 6 to 20)
 choice 3: display total number of spaces used on a specific day
 choice 4: display total number of accessible spaces used for the whole 14-day period (count number of
elements not set to “Free” for spaces 1 to 5 for each of the 14 days)
 choice 5: display total number of general spaces used for the whole 14-day period (count number of
elements not set to “Free” for spaces 6 to 20 for each of the 14 days)
 choice 6: display total number of spaces used for the whole 14-day period (count number of elements
not set to “Free”)
© Muzzammil Muttur – 2022 9
Pseudocode Solutions
© Muzzammil Muttur – 2022 10
TASK 1
DECLARE dayNumber, startingArrayID : INTEGER
DECLARE i, Count, choice : INTEGER
DECLARE VisitorName, CarLicenseNumber : STRING
DECLARE FreeLocationFound : BOOLEAN
DECLARE TotalAvailableParkingSlots : INTEGER
DECLARE ParkingBookingName[280] : STRING
DECLARE ParkingBookingCarNumber[280] : STRING
//initialize both arrays
FOR i  1 To 280
ParkingBookingName[i]  "Free"
ParkingBookingCarNumber[i]  "Free"
Next i
DO
OUTPUT "Parking Space Booking System"
OUTPUT "1. Make Booking"
OUTPUT "2. Delete All Stored Data"
OUTPUT "3. Exit"
OUTPUT "Enter your choice number: "
INPUT choice
IF choice = 1 THEN
REPEAT
OUTPUT "Enter day number [1 to 14]: "
INPUT dayNumber
UNTIL dayNumber >= 1 AND dayNumber <= 14
startingArrayID  ((dayNumber - 1) * 20) + 1
Count  0
FreeLocationFound  FALSE
TotalAvailableParkingSlots  20
REPEAT
IF ParkingBookingName [startingArrayID + Count] = "Free" THEN
FreeLocationFound  TRUE
ELSE
Count  Count + 1
END IF
UNTIL Count = TotalAvailableParkingSlots OR FreeLocationFound = TRUE
IF FreeLocationFound = TRUE THEN
OUTPUT "Enter visitor name: "
INPUT VisitorName
OUTPUT “Enter car license number: "
INPUT CarLicenseNumber
ParkingBookingName[startingArrayID + Count]  VisitorName
ParkingBookingCarNumber[startingArrayID + Count]  CarLicenseNumber
OUTPUT “Parking slot allocated: “, Count+1
© Muzzammil Muttur – 2022 11
End If
If FreeLocationFound = False Then
OUTPUT "Sorry. No more free locations on selected day."
End If
//delete all data over the last two weeks period
ELSEIF choice = 2 THEN
FOR i = 1 TO 280
ParkingBookingName[i]  "Free"
ParkingBookingCarNumber[i]  "Free"
NEXT i
END IF
UNTIL choice = 3
© Muzzammil Muttur – 2022 12
TASK 2
DECLARE dayNumber, startingArrayID : INTEGER
DECLARE i, Count, choice As INTEGER
DECLARE VisitorName, CarLicenseNumber : STRING
DECLARE FreeLocationFound : BOOLEAN
DECLARE parkingSlotNumber : INTEGER
DECLARE AccessibleSpaceNeeded : CHAR
DECLARE TotalAvailableParkingSpaces : INTEGER
DECLARE ParkingBookingName[280] : STRING
DECLARE ParkingBookingCarNumber[280] : STRING
FOR i  1 TO 280
ParkingBookingName[i]  "Free"
ParkingBookingCarNumber[i]  "Free"
NEXT i
Do
OUTPUT "Parking Space Booking System"
OUTPUT "1. Make Booking"
OUTPUT "2. Delete All Stored Data"
OUTPUT "3. Exit"
OUTPUT "Enter your choice number: "
INPUT choice
IF choice = 1 THEN
REPEAT
OUTPUT "Enter day number [1 to 14]: "
INPUT dayNumber
UNTIL dayNumber >= 1 AND dayNumber <= 14
startingArrayID  ((dayNumber - 1) * 20) + 1
OUTPUT "Do you need an accesible parking space? [Y/N]"
INPUT AccessibleSpaceNeeded
FreeLocationFound  FALSE
IF AccessibleSpaceNeeded = "Y" THEN
Count  0
TotalAvailableParkingSpaces  20
REPEAT
IF ParkingBookingName [startingArrayID + Count] = "Free" THEN
FreeLocationFound  TRUE
ELSE
Count  Count + 1
END IF
UNTIL Count = TotalAvailableParkingSpaces OR FreeLocationFound = TRUE
© Muzzammil Muttur – 2022 13
ELSEIF AccessibleSpaceNeeded = "N" THEN
TotalAvailableParkingSpaces  15
Count  19
REPEAT
IF ParkingBookingName [startingArrayID + Count] = "Free" THEN
FreeLocationFound  TRUE
ELSE
Count  Count - 1
END IF
UNTIL Count = 4 OR FreeLocationFound = TRUE
END IF
IF FreeLocationFound = TRUE THEN
OUTPUT "Enter visitor name: "
INPUT VisitorName
OUTPUT "Enter car license number: "
INPUT CarLicenseNumber
ParkingBookingName [startingArrayID + Count]  VisitorName
ParkingBookingCarNumber [startingArrayID + Count] CarLicenseNumber
OUTPUT "Parking space number booked: " , Count + 1
END IF
IF FreeLocationFound = FALSE THEN
OUTPUT "Sorry. No more free locations on selected day."
END IF
ELSEIF choice = 2 THEN
FOR i  1 TO 280
ParkingBookingName[i]  "Free"
ParkingBookingCarNumber[i]  "Free"
NEXT
END IF
UNTIL choice = 3
© Muzzammil Muttur – 2022 14
TASK 3
DECLARE dayNumber, startingArrayID : INTEGER
DECLARE i, Count, choice, statisticsChoice, parkingCount : INTEGER
DECLARE VisitorName, CarLicenseNumber : STRING
DECLARE FreeLocationFound : BOOLEAN
DECLARE parkingSlotNumber : INTEGER
DECLARE AccessibleSpaceNeeded : CHAR
DECLARE TotalAvailableParkingSpaces : INTEGER
DECLARE ParkingBookingName[280] : STRING
DECLARE ParkingBookingCarNumber[280]: STRING
FOR i  1 TO 280
ParkingBookingName[i]  "Free"
ParkingBookingCarNumber[i]  "Free"
NEXT i
REPEAT
OUTPUT"Parking Space Booking System"
OUTPUT"1. Make Booking"
OUTPUT"2. Delete All Stored Data"
OUTPUT"3. Show Statistics"
OUTPUT"4. Exit"
OUTPUT"Enter your choice number: "
INPUT choice
IF choice = 1 THEN
REPEAT
OUTPUT"Enter day number [1 to 14]: "
INPUT dayNumber
UNTIL dayNumber >= 1 AND dayNumber <= 14
startingArrayID = ((dayNumber - 1) * 20) + 1
OUTPUT "Do you need an accesible parking space? [Y/N]"
INPUT AccessibleSpaceNeeded
FreeLocationFound  FALSE
IF AccessibleSpaceNeeded = "Y" THEN
Count  0
TotalAvailableParkingSpaces  20
REPEAT
IF ParkingBookingName[startingArrayID + Count]  "Free" THEN
FreeLocationFound  True
ELSE
Count = Count + 1
END IF
© Muzzammil Muttur – 2022 15
UNTIL Count = TotalAvailableParkingSpaces OR FreeLocationFound =
TRUE
ELSEIF AccessibleSpaceNeeded = "N" THEN
TotalAvailableParkingSpaces  15
Count  19
REPEAT
IF ParkingBookingName[startingArrayID + Count] = "Free" THEN
FreeLocationFound  True
ELSE
Count  Count - 1
END IF
UNTIL Count = 4 OR FreeLocationFound = TRUE
END IF
IF FreeLocationFound = TRUE THEN
OUTPUT"Enter visitor name: "
INPUT VisitorName
OUTPUT"Enter car license number: "
INPUT CarLicenseNumber
ParkingBookingName[startingArrayID + Count]  VisitorName
ParkingBookingCarNumber[startingArrayID + Count]  CarLicenseNumber
OUTPUT "Parking space number booked: " , Count + 1
END IF
IF FreeLocationFound = FALSE THEN
OUTPUT "Sorry. No more free locations on selected day."
END IF
ELSEIF choice = 2 THEN
FOR i  1 TO 280
ParkingBookingName[i]  "Free"
ParkingBookingCarNumber[i]  "Free"
NEXT i
'show statistics
ELSEIF choice = 3 THEN
OUTPUT "1 - Number of accessible spaces used on a specific day"
OUTPUT "2 - Number of general spaces used on a specific day"
OUTPUT "3 - Total number of parking spaces used on a specific day"
OUTPUT "4 - Total number accessible spaces used on whole 14-day period"
OUTPUT "5 - Total number general spaces used on whole 14-day period"
OUTPUT "6 - Total number of parking spaces used on whole 14-day period"
OUTPUT "7 - Back to main menu"
© Muzzammil Muttur – 2022 16
OUTPUT"Enter your choice number: "
INPUT statisticsChoice
IF statisticsChoice = 1 THEN
OUTPUT"Enter day number [1-14]: "
INPUT dayNumber
startingArrayID  ((dayNumber - 1) * 20) + 1
parkingCount  0
FOR i  0 TO 4
IF ParkingBookingName[startingArrayID + i] <> "Free" THEN
parkingCount  parkingCount + 1
END IF
NEXT i
OUTPUT"Number of accessible spaces used on day ",dayNumber, ": ",
parkingCount
END IF
IF statisticsChoice = 2 THEN
OUTPUT"Enter day number [1-14]: "
INPUT dayNumber
startingArrayID  ((dayNumber - 1) * 20) + 1
parkingCount  0
FOR i  5 TO 19
IF ParkingBookingName[startingArrayID + i] <> "Free" THEN
parkingCount  parkingCount + 1
END IF
NEXT i
OUTPUT "Number of accessible spaces used on day ",dayNumber,": "
,parkingCount
END IF
IF statisticsChoice = 3 THEN
OUTPUT"Enter day number [1-14]: "
INPUT dayNumber
startingArrayID  ((dayNumber - 1) * 20) + 1
parkingCount  0
FOR i  0 TO 19
IF ParkingBookingName[startingArrayID + i] <> "Free" THEN
parkingCount  parkingCount + 1
END IF
NEXT i
OUTPUT "Number of accessible spaces used on day ",dayNumber,": "
,parkingCount
© Muzzammil Muttur – 2022 17
END IF
IF statisticsChoice = 4 THEN
parkingCount  0
FOR dayNumber = 1 TO 14
startingArrayID  ((dayNumber - 1) * 20) + 1
FOR i  0 TO 4
IF ParkingBookingName[startingArrayID + i] <> "Free" THEN
parkingCount = parkingCount + 1
END IF
NEXT i
NEXT dayNumber
OUTPUT "Number of accessible spaces used on day ",dayNumber,":
",parkingCount
END IF
IF statisticsChoice = 5 THEN
parkingCount  0
FOR dayNumber  1 TO 14
startingArrayID  ((dayNumber - 1) * 20) + 1
FOR i  5 TO 19
IF ParkingBookingName[startingArrayID + i] <> "Free" THEN
parkingCount  parkingCount + 1
END IF
NEXT i
NEXT dayNumber
OUTPUT"Number of general spaces used on day ",dayNumber,": ",
parkingCount
END IF
IF statisticsChoice = 6 THEN
parkingCount  0
FOR dayNumber = 1 TO 14
startingArrayID  ((dayNumber - 1) * 20) + 1
FOR i  0 TO 19
IF ParkingBookingName[startingArrayID + i] <> "Free" THEN
parkingCount  parkingCount + 1
END IF
NEXT i
NEXT dayNumber
© Muzzammil Muttur – 2022 18
OUTPUT"Number of parking spaces used on day ",dayNumber,": ",
parkingCount
END IF
END IF
UNTIL choice = 4
© Muzzammil Muttur – 2022 19
USING CASE STRUCTURE
CASE structure could have been used to implement the different menu options.
A subroutine is then called for each menu option. The following menu is displayed for Task 3.
Parking Space Booking System
1. Make Booking
2. Delete All Stored Data
3. Show Statistics
4. Exit
Enter your choice number:
REPEAT
OUTPUT "Parking Space Booking System"
OUTPUT "1. Make Booking"
OUTPUT "2. Delete All Stored Data"
OUTPUT "3. Show Statistics"
OUTPUT "4. Exit"
OUTPUT "Enter your choice number: "
INPUT choice
CASE menuChoice OF
1 : makeBooking ()
2 : DeleteAllData()
3 : ShowStatisticsMenu()
4 : exitProgram()
OTHERWISE Output ”Enter a number between 1 and 4.”
ENDCASE
Until Choice >= 1 and Choice <= 4
© Muzzammil Muttur – 2022 20
DATA VALIDATION
Validating data input could be done using a Repeat…Until loop as follows:
The following data input:
OUTPUT"Enter day number [1 to 14]: "
INPUT dayNumber
Is validated as follows:
REPEAT
OUTPUT"Enter day number [1 to 14]: "
INPUT dayNumber
UNTIL dayNumber >= 1 AND dayNumber <= 14
© Muzzammil Muttur – 2022 21
Potential Exam Questions
Based on Past CIE Exam Papers
© Muzzammil Muttur – 2022 22
1 (a) Write pseudocode for declaring a variable to be used.
DECLARE VisitorName : STRING
DECLARE dayNumber : INTEGER
(b) Give an example of a constant you have used.
AcessibleSpaces could have been used as a constant. It would then be declared and
initialised at the start of the program.
CONSTANT AcessibleSpaces : INTEGER
AcessibleSpaces  5
2 List three variables in your solution and what they are used for.
Variable 1:
 FreeLocationFound
 BOOLEAN data type
 It is a flag used to indicate if a free location has been found for the requested day.
Variable 2:
 AccessibleSpaceNeeded
 CHAR data type
 It is used to store the answer to the question: “Is an accessible parking space needed?
[Y/N]”
 Answer to the question is either ‘Y’ or ‘N’.
Variable 3:
 dayNumber
 INTEGER data type
 It is used to store the user input for the day number when to make the booking (must be in
the range 1 to 14 inclusive).
3 Give three examples of test data for day number (day on which to make parking space booking).
Normal data: 1, 2, 5, 8, 10, 14
Abnormal data: 0, 15, three, $3.40
Borderline/Extreme data: 1, 14 (borderline and normal data);
0, 15 (borderline and abnormal data)
4 Describe the arrays you could have used in Task 1. Include the name, data type, use and sample data
for each array.
The two arrays used are:
- Array 1: ParkingBookingName
- Data type: STRING
- SIZE: 280
- Used to store customer names when booking a parking space
© Muzzammil Muttur – 2022 23
- Example: John Smith
- Array 2: ParkingBookingCarNumber
- Data type: STRING
- SIZE: 280
- Used to store car license number when booking a parking space
- Example: B1458
5 Show any validation check you have used in your solution
REPEAT
OUTPUT"Enter day number [1 to 14]: "
INPUT dayNumber
UNTIL dayNumber >= 1 AND dayNumber <= 14
6 Explain how your program checks that there is a free space (general parking space) for the day
requested and identifies the slot number to be allocated.
startingArrayID = ((dayNumber - 1) * 20) + 1
OUTPUT "Do you need an accesible parking space? [Y/N]"
INPUT AccessibleSpaceNeeded
FreeLocationFound  FALSE
IF AccessibleSpaceNeeded = "Y" THEN
Count  0
TotalAvailableParkingSpaces  20
REPEAT
IF ParkingBookingName[startingArrayID + Count]  "Free" THEN
FreeLocationFound  True
ELSE
Count = Count + 1
END IF
UNTIL Count = TotalAvailableParkingSpaces OR FreeLocationFound = TRUE
ELSEIF AccessibleSpaceNeeded = "N" THEN
TotalAvailableParkingSpaces  15
Count  19
REPEAT
IF ParkingBookingName[startingArrayID + Count] = "Free" THEN
FreeLocationFound  True
ELSE
Count  Count - 1
END IF
UNTIL Count = 5 OR FreeLocationFound = TRUE
END IF
7 Explain how your program for Task 3 calculates the statistics for the number of general parking spaces
used over the 14-day period.
Any programming statements used in your answer must be fully explained.
parkingCount  0
FOR dayNumber  1 TO 14
startingArrayID  ((dayNumber - 1) * 20) + 1
© Muzzammil Muttur – 2022 24
FOR i  5 TO 19
IF ParkingBookingName[startingArrayID + i] <> "Free" THEN
parkingCount  parkingCount + 1
END IF
NEXT i
NEXT dayNumber
OUTPUT"Number of accessible spaces used on day ",dayNumber,": ",
parkingCount
8 Comment on the efficiency of your design.
The program has been made as efficient as possible with no block of code being uselessly repeated and
duplicated. A single array of 280 locations has been used to store customer names for the whole 14-day
period instead of 14 individual arrays. The program simply needs to move to the starting array location
depending on the day chose. The same technique has been used to store customer license numbers.
Additionally: you could be asked to write the pseudocode for Task 2 or Task 3 assuming that Task 1 or Task 2
have been completed.
© Muzzammil Muttur – 2022 25
Program Code
Microsoft Visual Basic Console Mode
© Muzzammil Muttur – 2022 26
TASK 1
Module Module1
Sub Main()
Dim dayNumber, startingArrayID As Integer
Dim i, Count, choice As Integer
Dim VisitorName, CarLicenseNumber As String
Dim FreeLocationFound As Boolean
Dim TotalAvailableParkingSlots As Integer
Dim ParkingBookingName(280) As String
Dim ParkingBookingCarNumber(280) As String
For i = 1 To 280
ParkingBookingName(i) = "Free"
ParkingBookingCarNumber(i) = "Free"
Next
Do
Console.Clear()
Console.WriteLine("Parking Space Booking System")
Console.WriteLine("1. Make Booking")
Console.WriteLine("2. Delete All Stored Data")
Console.WriteLine("3. Exit")
Console.WriteLine()
Console.WriteLine("Enter your choice number: ")
choice = Console.ReadLine
If choice = 1 Then
Do
Console.WriteLine("Enter day number [1 to 14]: ")
dayNumber = Console.ReadLine
Loop Until dayNumber >= 1 And dayNumber <= 14
startingArrayID = ((dayNumber - 1) * 20) + 1
Count = 0
FreeLocationFound = False
TotalAvailableParkingSlots = 20
Do
If ParkingBookingName(startingArrayID + Count) = "Free" Then
FreeLocationFound = True
Else
Count = Count + 1
End If
Loop Until Count = TotalAvailableParkingSlots Or FreeLocationFound = True
If FreeLocationFound = True Then
Console.WriteLine("Enter visitor name: ")
VisitorName = Console.ReadLine
Console.WriteLine("Enter car license number: ")
CarLicenseNumber = Console.ReadLine
ParkingBookingName(startingArrayID + Count) = VisitorName
© Muzzammil Muttur – 2022 27
ParkingBookingCarNumber(startingArrayID + Count) = CarLicenseNumber
Console.WriteLine(startingArrayID + Count)
Console.WriteLine("Parking space number booked: " , Count + 1)
CONSOLE.READLINE()
End If
If FreeLocationFound = False Then
Console.WriteLine("Sorry. No more free locations on selected day.")
CONSOLE.READLINE()
End If
ElseIf choice = 2 Then
For i = 1 To 280
ParkingBookingName(i) = "Free"
ParkingBookingCarNumber(i) = "Free"
Next
End If
Loop Until choice = 3
CONSOLE.READLINE()
End Sub
End Module
© Muzzammil Muttur – 2022 28
TASK 2
Module Module1
Sub Main()
Dim dayNumber, startingArrayID As Integer
Dim i, Count, choice As Integer
Dim VisitorName, CarLicenseNumber As String
Dim FreeLocationFound As Boolean
Dim parkingSlotNumber As Integer
Dim AccessibleSpaceNeeded As Char
Dim TotalAvailableParkingSpaces As Integer
Dim ParkingBookingName(280) As String
Dim ParkingBookingCarNumber(280) As String
For i = 1 To 280
ParkingBookingName(i) = "Free"
ParkingBookingCarNumber(i) = "Free"
Next
Do
Console.Clear()
Console.WriteLine("Parking Space Booking System")
Console.WriteLine("1. Make Booking")
Console.WriteLine("2. Delete All Stored Data")
Console.WriteLine("3. Exit")
Console.WriteLine()
Console.WriteLine("Enter your choice number: ")
choice = Console.ReadLine
If choice = 1 Then
Do
Console.WriteLine("Enter day number [1 to 14]: ")
dayNumber = Console.ReadLine
Loop Until dayNumber >= 1 And dayNumber <= 14
startingArrayID = ((dayNumber - 1) * 20) + 1
Console.WriteLine("Do you need an accesible parking space? [Y/N]")
AccessibleSpaceNeeded = Console.ReadLine
FreeLocationFound = False
If AccessibleSpaceNeeded = "Y" Then
Count = 0
TotalAvailableParkingSpaces = 20
Do
If ParkingBookingName(startingArrayID + Count) = "Free" Then
FreeLocationFound = True
Else
Count = Count + 1
End If
Loop Until Count = TotalAvailableParkingSpaces Or FreeLocationFound = True
ElseIf AccessibleSpaceNeeded = "N" Then
TotalAvailableParkingSpaces = 15
Count = 19
Do
If ParkingBookingName(startingArrayID + Count) = "Free" Then
FreeLocationFound = True
Else
© Muzzammil Muttur – 2022 29
Count = Count - 1
End If
Loop Until Count = 4 Or FreeLocationFound = True
End If
If FreeLocationFound = True Then
Console.WriteLine("Enter visitor name: ")
VisitorName = Console.ReadLine
Console.WriteLine("Enter car license number: ")
CarLicenseNumber = Console.ReadLine
ParkingBookingName(startingArrayID + Count) = VisitorName
ParkingBookingCarNumber(startingArrayID + Count) = CarLicenseNumber
Console.WriteLine(startingArrayID + Count)
Console.WriteLine("Parking space number booked: " & Count + 1)
CONSOLE.READLINE()
End If
If FreeLocationFound = False Then
Console.WriteLine("Sorry. No more free locations on selected day.")
CONSOLE.READLINE()
End If
ElseIf choice = 2 Then
For i = 1 To 280
ParkingBookingName(i) = "Free"
ParkingBookingCarNumber(i) = "Free"
Next
End If
Loop Until choice = 3
CONSOLE.READLINE()
End Sub
End Module
© Muzzammil Muttur – 2022 30
TASK 3
Module Module1
Sub Main()
Dim dayNumber, startingArrayID As Integer
Dim i, Count, choice, statisticsChoice, parkingCount As Integer
Dim VisitorName, CarLicenseNumber As String
Dim FreeLocationFound As Boolean
Dim parkingSlotNumber As Integer
Dim AccessibleSpaceNeeded As Char
Dim TotalAvailableParkingSpaces As Integer
Dim ParkingBookingName(280) As String
Dim ParkingBookingCarNumber(280) As String
For i = 1 To 280
ParkingBookingName(i) = "Free"
ParkingBookingCarNumber(i) = "Free"
Next
Do
Console.Clear()
Console.WriteLine("Parking Space Booking System")
Console.WriteLine("1. Make Booking")
Console.WriteLine("2. Delete All Stored Data")
Console.WriteLine("3. Show Statistics")
Console.WriteLine("4. Exit")
Console.WriteLine()
Console.WriteLine("Enter your choice number: ")
choice = Console.ReadLine
If choice = 1 Then
Do
Console.WriteLine("Enter day number [1 to 14]: ")
dayNumber = Console.ReadLine
Loop Until dayNumber >= 1 And dayNumber <= 14
startingArrayID = ((dayNumber - 1) * 20) + 1
Console.WriteLine("Do you need an accesible parking space? [Y/N]")
AccessibleSpaceNeeded = Console.ReadLine
FreeLocationFound = False
If AccessibleSpaceNeeded = "Y" Then
Count = 0
TotalAvailableParkingSpaces = 20
Do
If ParkingBookingName(startingArrayID + Count) = "Free" Then
FreeLocationFound = True
Else
Count = Count + 1
End If
Loop Until Count = TotalAvailableParkingSpaces Or FreeLocationFound = True
ElseIf AccessibleSpaceNeeded = "N" Then
TotalAvailableParkingSpaces = 15
Count = 19
Do
If ParkingBookingName(startingArrayID + Count) = "Free" Then
FreeLocationFound = True
Else
© Muzzammil Muttur – 2022 31
Count = Count - 1
End If
Loop Until Count = 4 Or FreeLocationFound = True
End If
If FreeLocationFound = True Then
Console.WriteLine("Enter visitor name: ")
VisitorName = Console.ReadLine
Console.WriteLine("Enter car license number: ")
CarLicenseNumber = Console.ReadLine
ParkingBookingName(startingArrayID + Count) = VisitorName
ParkingBookingCarNumber(startingArrayID + Count) = CarLicenseNumber
Console.WriteLine(startingArrayID + Count)
Console.WriteLine("Parking space number booked: " & Count + 1)
CONSOLE.READLINE()
End If
If FreeLocationFound = False Then
Console.WriteLine("Sorry. No more free locations on selected day.")
CONSOLE.READLINE()
End If
ElseIf choice = 2 Then
For i = 1 To 280
ParkingBookingName(i) = "Free"
ParkingBookingCarNumber(i) = "Free"
Next
'show statistics
ElseIf choice = 3 Then
Console.Clear()
Console.WriteLine("1 - Number of accessible spaces used on a specific day")
Console.WriteLine("2 - Number of general spaces used on a specific day")
Console.WriteLine("3 - Total number of parking spaces used on a specific day")
Console.WriteLine("4 - Total number accessible spaces used on whole 14-day period")
Console.WriteLine("5 - Total number general spaces used on whole 14-day period")
Console.WriteLine("6 - Total number of parking spaces used on whole 14-day period")
Console.WriteLine("7 - Back to main menu")
Console.WriteLine()
Console.WriteLine("Enter your choice number: ")
statisticsChoice = Console.ReadLine
If statisticsChoice = 1 Then
Console.WriteLine("Enter day number [1-14]: ")
dayNumber = Console.ReadLine
startingArrayID = ((dayNumber - 1) * 20) + 1
parkingCount = 0
For i = 0 To 4
If ParkingBookingName(startingArrayID + i) <> "Free" Then
parkingCount = parkingCount + 1
End If
Next
Console.Clear()
Console.WriteLine("Number of accessible spaces used on day " & dayNumber & ": " &
parkingCount)
CONSOLE.READLINE()
End If
© Muzzammil Muttur – 2022 32
If statisticsChoice = 2 Then
Console.WriteLine("Enter day number [1-14]: ")
dayNumber = Console.ReadLine
startingArrayID = ((dayNumber - 1) * 20) + 1
parkingCount = 0
For i = 5 To 19
If ParkingBookingName(startingArrayID + i) <> "Free" Then
parkingCount = parkingCount + 1
End If
Next
Console.Clear()
Console.WriteLine("Number of accessible spaces used on day " & dayNumber & ": " &
parkingCount)
CONSOLE.READLINE()
End If
If statisticsChoice = 3 Then
Console.WriteLine("Enter day number [1-14]: ")
dayNumber = Console.ReadLine
startingArrayID = ((dayNumber - 1) * 20) + 1
parkingCount = 0
For i = 0 To 19
If ParkingBookingName(startingArrayID + i) <> "Free" Then
parkingCount = parkingCount + 1
End If
Next
Console.Clear()
Console.WriteLine("Number of accessible spaces used on day " & dayNumber & ": " &
parkingCount)
CONSOLE.READLINE()
End If
If statisticsChoice = 4 Then
parkingCount = 0
For dayNumber = 1 To 14
startingArrayID = ((dayNumber - 1) * 20) + 1
For i = 0 To 4
If ParkingBookingName(startingArrayID + i) <> "Free" Then
parkingCount = parkingCount + 1
End If
Next
Next
Console.WriteLine("Number of accessible spaces used on day " & dayNumber & ": " &
parkingCount)
CONSOLE.READLINE()
End If
If statisticsChoice = 5 Then
parkingCount = 0
For dayNumber = 1 To 14
startingArrayID = ((dayNumber - 1) * 20) + 1
© Muzzammil Muttur – 2022 33
For i = 5 To 19
If ParkingBookingName(startingArrayID + i) <> "Free" Then
parkingCount = parkingCount + 1
End If
Next
Next
Console.WriteLine("Number of accessible spaces used on day " & dayNumber & ": " &
parkingCount)
CONSOLE.READLINE()
End If
If statisticsChoice = 6 Then
parkingCount = 0
For dayNumber = 1 To 14
startingArrayID = ((dayNumber - 1) * 20) + 1
For i = 0 To 19
If ParkingBookingName(startingArrayID + i) <> "Free" Then
parkingCount = parkingCount + 1
End If
Next
Next
Console.WriteLine("Number of accessible spaces used on day " & dayNumber & ": " &
parkingCount)
Console.ReadLine()
End If
End If
Loop Until choice = 4
CONSOLE.READLINE()
End Sub
End Module

More Related Content

Similar to document.pdf

INT213 Project Report: Income Tax Calculator
INT213 Project Report: Income Tax CalculatorINT213 Project Report: Income Tax Calculator
INT213 Project Report: Income Tax CalculatorQazi Maaz Arshad
 
IRJET- Vehicle Number Plate Detection using Image Processing
IRJET-  	  Vehicle Number Plate Detection using Image ProcessingIRJET-  	  Vehicle Number Plate Detection using Image Processing
IRJET- Vehicle Number Plate Detection using Image ProcessingIRJET Journal
 
IRJET- Smart Parking System
IRJET-  	  Smart Parking SystemIRJET-  	  Smart Parking System
IRJET- Smart Parking SystemIRJET Journal
 
Course project for CEE 4674
Course project for CEE 4674Course project for CEE 4674
Course project for CEE 4674Junqi Hu
 
Flink Forward Berlin 2018: Dawid Wysakowicz - "Detecting Patterns in Event St...
Flink Forward Berlin 2018: Dawid Wysakowicz - "Detecting Patterns in Event St...Flink Forward Berlin 2018: Dawid Wysakowicz - "Detecting Patterns in Event St...
Flink Forward Berlin 2018: Dawid Wysakowicz - "Detecting Patterns in Event St...Flink Forward
 
Internal valuation trg
Internal  valuation trgInternal  valuation trg
Internal valuation trgArnab das
 
Pay N Parking Solution
Pay N Parking Solution  Pay N Parking Solution
Pay N Parking Solution MK Dani
 
Project Proposal Presentation-C.O.D.E-7 Solutions
Project Proposal Presentation-C.O.D.E-7 SolutionsProject Proposal Presentation-C.O.D.E-7 Solutions
Project Proposal Presentation-C.O.D.E-7 SolutionsDiren Dantanarayana
 
IRJET- Smart Parking : Parking Occupancy Monitoring and Visualisation Syst...
IRJET- 	  Smart Parking : Parking Occupancy Monitoring and Visualisation Syst...IRJET- 	  Smart Parking : Parking Occupancy Monitoring and Visualisation Syst...
IRJET- Smart Parking : Parking Occupancy Monitoring and Visualisation Syst...IRJET Journal
 
Value for Money Resale Flats in Singapore Documentation
Value for Money Resale Flats in Singapore DocumentationValue for Money Resale Flats in Singapore Documentation
Value for Money Resale Flats in Singapore DocumentationDarren Chia
 
IRJET- Surveying using Drones and Providing Results by using Photogrammme...
IRJET-  	  Surveying using Drones and Providing Results by using Photogrammme...IRJET-  	  Surveying using Drones and Providing Results by using Photogrammme...
IRJET- Surveying using Drones and Providing Results by using Photogrammme...IRJET Journal
 
IRJET - Surveying using Drones and Providing Results by using Photogrammm...
IRJET -  	  Surveying using Drones and Providing Results by using Photogrammm...IRJET -  	  Surveying using Drones and Providing Results by using Photogrammm...
IRJET - Surveying using Drones and Providing Results by using Photogrammm...IRJET Journal
 
Traffic Volume Study And Congestion Solution Using VisSim Software
Traffic Volume Study And Congestion Solution Using VisSim SoftwareTraffic Volume Study And Congestion Solution Using VisSim Software
Traffic Volume Study And Congestion Solution Using VisSim SoftwareIRJET Journal
 
IRJET- Modern E-Parking System for Smart Cities
IRJET-  	  Modern E-Parking System for Smart CitiesIRJET-  	  Modern E-Parking System for Smart Cities
IRJET- Modern E-Parking System for Smart CitiesIRJET Journal
 
IRJET- Real Time Fuel Estimation using Micro Controller and Android App
IRJET- Real Time Fuel Estimation using Micro Controller and Android AppIRJET- Real Time Fuel Estimation using Micro Controller and Android App
IRJET- Real Time Fuel Estimation using Micro Controller and Android AppIRJET Journal
 
cars design code power system detai.pptx
cars design code power system detai.pptxcars design code power system detai.pptx
cars design code power system detai.pptxabomoayad19309
 
IOT BASED AUTOMATED PETROL PUMP
IOT BASED AUTOMATED PETROL PUMPIOT BASED AUTOMATED PETROL PUMP
IOT BASED AUTOMATED PETROL PUMPIRJET Journal
 
Predicting model for prices of used cars
Predicting model for prices of used carsPredicting model for prices of used cars
Predicting model for prices of used carsHARPREETSINGH1862
 
Parking Ticket SimulatorFor this assignment you will design a se.docx
Parking Ticket SimulatorFor this assignment you will design a se.docxParking Ticket SimulatorFor this assignment you will design a se.docx
Parking Ticket SimulatorFor this assignment you will design a se.docxdanhaley45372
 

Similar to document.pdf (20)

INT213 Project Report: Income Tax Calculator
INT213 Project Report: Income Tax CalculatorINT213 Project Report: Income Tax Calculator
INT213 Project Report: Income Tax Calculator
 
IRJET- Vehicle Number Plate Detection using Image Processing
IRJET-  	  Vehicle Number Plate Detection using Image ProcessingIRJET-  	  Vehicle Number Plate Detection using Image Processing
IRJET- Vehicle Number Plate Detection using Image Processing
 
IRJET- Smart Parking System
IRJET-  	  Smart Parking SystemIRJET-  	  Smart Parking System
IRJET- Smart Parking System
 
Course project for CEE 4674
Course project for CEE 4674Course project for CEE 4674
Course project for CEE 4674
 
Smart parking
Smart parkingSmart parking
Smart parking
 
Flink Forward Berlin 2018: Dawid Wysakowicz - "Detecting Patterns in Event St...
Flink Forward Berlin 2018: Dawid Wysakowicz - "Detecting Patterns in Event St...Flink Forward Berlin 2018: Dawid Wysakowicz - "Detecting Patterns in Event St...
Flink Forward Berlin 2018: Dawid Wysakowicz - "Detecting Patterns in Event St...
 
Internal valuation trg
Internal  valuation trgInternal  valuation trg
Internal valuation trg
 
Pay N Parking Solution
Pay N Parking Solution  Pay N Parking Solution
Pay N Parking Solution
 
Project Proposal Presentation-C.O.D.E-7 Solutions
Project Proposal Presentation-C.O.D.E-7 SolutionsProject Proposal Presentation-C.O.D.E-7 Solutions
Project Proposal Presentation-C.O.D.E-7 Solutions
 
IRJET- Smart Parking : Parking Occupancy Monitoring and Visualisation Syst...
IRJET- 	  Smart Parking : Parking Occupancy Monitoring and Visualisation Syst...IRJET- 	  Smart Parking : Parking Occupancy Monitoring and Visualisation Syst...
IRJET- Smart Parking : Parking Occupancy Monitoring and Visualisation Syst...
 
Value for Money Resale Flats in Singapore Documentation
Value for Money Resale Flats in Singapore DocumentationValue for Money Resale Flats in Singapore Documentation
Value for Money Resale Flats in Singapore Documentation
 
IRJET- Surveying using Drones and Providing Results by using Photogrammme...
IRJET-  	  Surveying using Drones and Providing Results by using Photogrammme...IRJET-  	  Surveying using Drones and Providing Results by using Photogrammme...
IRJET- Surveying using Drones and Providing Results by using Photogrammme...
 
IRJET - Surveying using Drones and Providing Results by using Photogrammm...
IRJET -  	  Surveying using Drones and Providing Results by using Photogrammm...IRJET -  	  Surveying using Drones and Providing Results by using Photogrammm...
IRJET - Surveying using Drones and Providing Results by using Photogrammm...
 
Traffic Volume Study And Congestion Solution Using VisSim Software
Traffic Volume Study And Congestion Solution Using VisSim SoftwareTraffic Volume Study And Congestion Solution Using VisSim Software
Traffic Volume Study And Congestion Solution Using VisSim Software
 
IRJET- Modern E-Parking System for Smart Cities
IRJET-  	  Modern E-Parking System for Smart CitiesIRJET-  	  Modern E-Parking System for Smart Cities
IRJET- Modern E-Parking System for Smart Cities
 
IRJET- Real Time Fuel Estimation using Micro Controller and Android App
IRJET- Real Time Fuel Estimation using Micro Controller and Android AppIRJET- Real Time Fuel Estimation using Micro Controller and Android App
IRJET- Real Time Fuel Estimation using Micro Controller and Android App
 
cars design code power system detai.pptx
cars design code power system detai.pptxcars design code power system detai.pptx
cars design code power system detai.pptx
 
IOT BASED AUTOMATED PETROL PUMP
IOT BASED AUTOMATED PETROL PUMPIOT BASED AUTOMATED PETROL PUMP
IOT BASED AUTOMATED PETROL PUMP
 
Predicting model for prices of used cars
Predicting model for prices of used carsPredicting model for prices of used cars
Predicting model for prices of used cars
 
Parking Ticket SimulatorFor this assignment you will design a se.docx
Parking Ticket SimulatorFor this assignment you will design a se.docxParking Ticket SimulatorFor this assignment you will design a se.docx
Parking Ticket SimulatorFor this assignment you will design a se.docx
 

Recently uploaded

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 

Recently uploaded (20)

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 

document.pdf

  • 1. © Muzzammil Muttur – 2022 1 CIE O Level November 2022 – Paper 2 Solutions for Pre-Release Material Version 2.1 ©Muzzammil Muttur – July 2022 Please feel free to distribute this document. No modifications allowed to this document without prior permission. Note: All modifications in new version are highlighted in green. Thank you to email all your suggestions, comments and feedback. Muzzammil Muttur 5 493 1972 Facebook Page: @mmuttur learnatedutech@gmail.com
  • 2. © Muzzammil Muttur – 2022 2 Pre Release Material
  • 3. © Muzzammil Muttur – 2022 3
  • 4. © Muzzammil Muttur – 2022 4 QUESTION BREAKDOWN ● Visitor car park has 20 spaces ● Car park spaces are numbered 1 to 20 ● Booking can be made visitors up to 2 weeks in advance ● To make a booking: visitor must provide license number of car and customer name ● The next available parking space (beginning at space 1) is allocated and given data is stored ● System needs to record car park bookings ● Program work for a period of two weeks SCENARIO ● person comes for visitor parking space booking ● user is shown a menu with three options: make a parking place booking, delete and reset all data structures (arrays) or exit the system ● person provides car license number and name ● system checks if there are free spaces for that day ● if there are free spaces for required day, then give next free space (starting from number 1) to customer and store data needed ASSUMPTIONS: ● a parking space is booked for a whole day ● a customer books one parking slot at a time ● no document is checked for accessible parking space
  • 5. © Muzzammil Muttur – 2022 5 Processing Required
  • 6. © Muzzammil Muttur – 2022 6 TASK 1  use arrays to store required data  arrays to store car license numbers and names of visitors who have booked car parking spaces  arrays must have enough spaces for a static period of two weeks  a visitor can request a parking space for any day within the two-week period  system must check that there are free spaces on the day requested  visitor enter their name and car license number for making booking  data will be stored in data structures (arrays)  parking space will be given for next available space for the day requested  if there are no free parking spaces for the day requested, the visitor is informed that booking cannot be done  visitor must be told the number of their parking space for that day  at the end of the two-week period, all data is to be deleted and system must be ready for the next two week period TASK 2  ask user if accessible space is needed  answer to be recorded as Y/N  if accessible space is to be given, then allocate the first free space (starting from  if no accessible space is to be given, then give the first free space as from space 20 (general spaces) and keep decrementing until parking space 6 is booked
  • 7. © Muzzammil Muttur – 2022 7 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
  • 8. © Muzzammil Muttur – 2022 8 TASK 3  calculate statistics based on the array used to store parking space booking  use a counter to access the array for the different days  show the user a menu to choose between the different statistics that can be generated  choice 1: display the number of accessible spaces used on a specific day (count number of elements not set to “Free” for spaces 1 to 5)  choice 2: display the number of general spaces used on a specific day (count number of elements not set to “Free” for spaces 6 to 20)  choice 3: display total number of spaces used on a specific day  choice 4: display total number of accessible spaces used for the whole 14-day period (count number of elements not set to “Free” for spaces 1 to 5 for each of the 14 days)  choice 5: display total number of general spaces used for the whole 14-day period (count number of elements not set to “Free” for spaces 6 to 20 for each of the 14 days)  choice 6: display total number of spaces used for the whole 14-day period (count number of elements not set to “Free”)
  • 9. © Muzzammil Muttur – 2022 9 Pseudocode Solutions
  • 10. © Muzzammil Muttur – 2022 10 TASK 1 DECLARE dayNumber, startingArrayID : INTEGER DECLARE i, Count, choice : INTEGER DECLARE VisitorName, CarLicenseNumber : STRING DECLARE FreeLocationFound : BOOLEAN DECLARE TotalAvailableParkingSlots : INTEGER DECLARE ParkingBookingName[280] : STRING DECLARE ParkingBookingCarNumber[280] : STRING //initialize both arrays FOR i  1 To 280 ParkingBookingName[i]  "Free" ParkingBookingCarNumber[i]  "Free" Next i DO OUTPUT "Parking Space Booking System" OUTPUT "1. Make Booking" OUTPUT "2. Delete All Stored Data" OUTPUT "3. Exit" OUTPUT "Enter your choice number: " INPUT choice IF choice = 1 THEN REPEAT OUTPUT "Enter day number [1 to 14]: " INPUT dayNumber UNTIL dayNumber >= 1 AND dayNumber <= 14 startingArrayID  ((dayNumber - 1) * 20) + 1 Count  0 FreeLocationFound  FALSE TotalAvailableParkingSlots  20 REPEAT IF ParkingBookingName [startingArrayID + Count] = "Free" THEN FreeLocationFound  TRUE ELSE Count  Count + 1 END IF UNTIL Count = TotalAvailableParkingSlots OR FreeLocationFound = TRUE IF FreeLocationFound = TRUE THEN OUTPUT "Enter visitor name: " INPUT VisitorName OUTPUT “Enter car license number: " INPUT CarLicenseNumber ParkingBookingName[startingArrayID + Count]  VisitorName ParkingBookingCarNumber[startingArrayID + Count]  CarLicenseNumber OUTPUT “Parking slot allocated: “, Count+1
  • 11. © Muzzammil Muttur – 2022 11 End If If FreeLocationFound = False Then OUTPUT "Sorry. No more free locations on selected day." End If //delete all data over the last two weeks period ELSEIF choice = 2 THEN FOR i = 1 TO 280 ParkingBookingName[i]  "Free" ParkingBookingCarNumber[i]  "Free" NEXT i END IF UNTIL choice = 3
  • 12. © Muzzammil Muttur – 2022 12 TASK 2 DECLARE dayNumber, startingArrayID : INTEGER DECLARE i, Count, choice As INTEGER DECLARE VisitorName, CarLicenseNumber : STRING DECLARE FreeLocationFound : BOOLEAN DECLARE parkingSlotNumber : INTEGER DECLARE AccessibleSpaceNeeded : CHAR DECLARE TotalAvailableParkingSpaces : INTEGER DECLARE ParkingBookingName[280] : STRING DECLARE ParkingBookingCarNumber[280] : STRING FOR i  1 TO 280 ParkingBookingName[i]  "Free" ParkingBookingCarNumber[i]  "Free" NEXT i Do OUTPUT "Parking Space Booking System" OUTPUT "1. Make Booking" OUTPUT "2. Delete All Stored Data" OUTPUT "3. Exit" OUTPUT "Enter your choice number: " INPUT choice IF choice = 1 THEN REPEAT OUTPUT "Enter day number [1 to 14]: " INPUT dayNumber UNTIL dayNumber >= 1 AND dayNumber <= 14 startingArrayID  ((dayNumber - 1) * 20) + 1 OUTPUT "Do you need an accesible parking space? [Y/N]" INPUT AccessibleSpaceNeeded FreeLocationFound  FALSE IF AccessibleSpaceNeeded = "Y" THEN Count  0 TotalAvailableParkingSpaces  20 REPEAT IF ParkingBookingName [startingArrayID + Count] = "Free" THEN FreeLocationFound  TRUE ELSE Count  Count + 1 END IF UNTIL Count = TotalAvailableParkingSpaces OR FreeLocationFound = TRUE
  • 13. © Muzzammil Muttur – 2022 13 ELSEIF AccessibleSpaceNeeded = "N" THEN TotalAvailableParkingSpaces  15 Count  19 REPEAT IF ParkingBookingName [startingArrayID + Count] = "Free" THEN FreeLocationFound  TRUE ELSE Count  Count - 1 END IF UNTIL Count = 4 OR FreeLocationFound = TRUE END IF IF FreeLocationFound = TRUE THEN OUTPUT "Enter visitor name: " INPUT VisitorName OUTPUT "Enter car license number: " INPUT CarLicenseNumber ParkingBookingName [startingArrayID + Count]  VisitorName ParkingBookingCarNumber [startingArrayID + Count] CarLicenseNumber OUTPUT "Parking space number booked: " , Count + 1 END IF IF FreeLocationFound = FALSE THEN OUTPUT "Sorry. No more free locations on selected day." END IF ELSEIF choice = 2 THEN FOR i  1 TO 280 ParkingBookingName[i]  "Free" ParkingBookingCarNumber[i]  "Free" NEXT END IF UNTIL choice = 3
  • 14. © Muzzammil Muttur – 2022 14 TASK 3 DECLARE dayNumber, startingArrayID : INTEGER DECLARE i, Count, choice, statisticsChoice, parkingCount : INTEGER DECLARE VisitorName, CarLicenseNumber : STRING DECLARE FreeLocationFound : BOOLEAN DECLARE parkingSlotNumber : INTEGER DECLARE AccessibleSpaceNeeded : CHAR DECLARE TotalAvailableParkingSpaces : INTEGER DECLARE ParkingBookingName[280] : STRING DECLARE ParkingBookingCarNumber[280]: STRING FOR i  1 TO 280 ParkingBookingName[i]  "Free" ParkingBookingCarNumber[i]  "Free" NEXT i REPEAT OUTPUT"Parking Space Booking System" OUTPUT"1. Make Booking" OUTPUT"2. Delete All Stored Data" OUTPUT"3. Show Statistics" OUTPUT"4. Exit" OUTPUT"Enter your choice number: " INPUT choice IF choice = 1 THEN REPEAT OUTPUT"Enter day number [1 to 14]: " INPUT dayNumber UNTIL dayNumber >= 1 AND dayNumber <= 14 startingArrayID = ((dayNumber - 1) * 20) + 1 OUTPUT "Do you need an accesible parking space? [Y/N]" INPUT AccessibleSpaceNeeded FreeLocationFound  FALSE IF AccessibleSpaceNeeded = "Y" THEN Count  0 TotalAvailableParkingSpaces  20 REPEAT IF ParkingBookingName[startingArrayID + Count]  "Free" THEN FreeLocationFound  True ELSE Count = Count + 1 END IF
  • 15. © Muzzammil Muttur – 2022 15 UNTIL Count = TotalAvailableParkingSpaces OR FreeLocationFound = TRUE ELSEIF AccessibleSpaceNeeded = "N" THEN TotalAvailableParkingSpaces  15 Count  19 REPEAT IF ParkingBookingName[startingArrayID + Count] = "Free" THEN FreeLocationFound  True ELSE Count  Count - 1 END IF UNTIL Count = 4 OR FreeLocationFound = TRUE END IF IF FreeLocationFound = TRUE THEN OUTPUT"Enter visitor name: " INPUT VisitorName OUTPUT"Enter car license number: " INPUT CarLicenseNumber ParkingBookingName[startingArrayID + Count]  VisitorName ParkingBookingCarNumber[startingArrayID + Count]  CarLicenseNumber OUTPUT "Parking space number booked: " , Count + 1 END IF IF FreeLocationFound = FALSE THEN OUTPUT "Sorry. No more free locations on selected day." END IF ELSEIF choice = 2 THEN FOR i  1 TO 280 ParkingBookingName[i]  "Free" ParkingBookingCarNumber[i]  "Free" NEXT i 'show statistics ELSEIF choice = 3 THEN OUTPUT "1 - Number of accessible spaces used on a specific day" OUTPUT "2 - Number of general spaces used on a specific day" OUTPUT "3 - Total number of parking spaces used on a specific day" OUTPUT "4 - Total number accessible spaces used on whole 14-day period" OUTPUT "5 - Total number general spaces used on whole 14-day period" OUTPUT "6 - Total number of parking spaces used on whole 14-day period" OUTPUT "7 - Back to main menu"
  • 16. © Muzzammil Muttur – 2022 16 OUTPUT"Enter your choice number: " INPUT statisticsChoice IF statisticsChoice = 1 THEN OUTPUT"Enter day number [1-14]: " INPUT dayNumber startingArrayID  ((dayNumber - 1) * 20) + 1 parkingCount  0 FOR i  0 TO 4 IF ParkingBookingName[startingArrayID + i] <> "Free" THEN parkingCount  parkingCount + 1 END IF NEXT i OUTPUT"Number of accessible spaces used on day ",dayNumber, ": ", parkingCount END IF IF statisticsChoice = 2 THEN OUTPUT"Enter day number [1-14]: " INPUT dayNumber startingArrayID  ((dayNumber - 1) * 20) + 1 parkingCount  0 FOR i  5 TO 19 IF ParkingBookingName[startingArrayID + i] <> "Free" THEN parkingCount  parkingCount + 1 END IF NEXT i OUTPUT "Number of accessible spaces used on day ",dayNumber,": " ,parkingCount END IF IF statisticsChoice = 3 THEN OUTPUT"Enter day number [1-14]: " INPUT dayNumber startingArrayID  ((dayNumber - 1) * 20) + 1 parkingCount  0 FOR i  0 TO 19 IF ParkingBookingName[startingArrayID + i] <> "Free" THEN parkingCount  parkingCount + 1 END IF NEXT i OUTPUT "Number of accessible spaces used on day ",dayNumber,": " ,parkingCount
  • 17. © Muzzammil Muttur – 2022 17 END IF IF statisticsChoice = 4 THEN parkingCount  0 FOR dayNumber = 1 TO 14 startingArrayID  ((dayNumber - 1) * 20) + 1 FOR i  0 TO 4 IF ParkingBookingName[startingArrayID + i] <> "Free" THEN parkingCount = parkingCount + 1 END IF NEXT i NEXT dayNumber OUTPUT "Number of accessible spaces used on day ",dayNumber,": ",parkingCount END IF IF statisticsChoice = 5 THEN parkingCount  0 FOR dayNumber  1 TO 14 startingArrayID  ((dayNumber - 1) * 20) + 1 FOR i  5 TO 19 IF ParkingBookingName[startingArrayID + i] <> "Free" THEN parkingCount  parkingCount + 1 END IF NEXT i NEXT dayNumber OUTPUT"Number of general spaces used on day ",dayNumber,": ", parkingCount END IF IF statisticsChoice = 6 THEN parkingCount  0 FOR dayNumber = 1 TO 14 startingArrayID  ((dayNumber - 1) * 20) + 1 FOR i  0 TO 19 IF ParkingBookingName[startingArrayID + i] <> "Free" THEN parkingCount  parkingCount + 1 END IF NEXT i NEXT dayNumber
  • 18. © Muzzammil Muttur – 2022 18 OUTPUT"Number of parking spaces used on day ",dayNumber,": ", parkingCount END IF END IF UNTIL choice = 4
  • 19. © Muzzammil Muttur – 2022 19 USING CASE STRUCTURE CASE structure could have been used to implement the different menu options. A subroutine is then called for each menu option. The following menu is displayed for Task 3. Parking Space Booking System 1. Make Booking 2. Delete All Stored Data 3. Show Statistics 4. Exit Enter your choice number: REPEAT OUTPUT "Parking Space Booking System" OUTPUT "1. Make Booking" OUTPUT "2. Delete All Stored Data" OUTPUT "3. Show Statistics" OUTPUT "4. Exit" OUTPUT "Enter your choice number: " INPUT choice CASE menuChoice OF 1 : makeBooking () 2 : DeleteAllData() 3 : ShowStatisticsMenu() 4 : exitProgram() OTHERWISE Output ”Enter a number between 1 and 4.” ENDCASE Until Choice >= 1 and Choice <= 4
  • 20. © Muzzammil Muttur – 2022 20 DATA VALIDATION Validating data input could be done using a Repeat…Until loop as follows: The following data input: OUTPUT"Enter day number [1 to 14]: " INPUT dayNumber Is validated as follows: REPEAT OUTPUT"Enter day number [1 to 14]: " INPUT dayNumber UNTIL dayNumber >= 1 AND dayNumber <= 14
  • 21. © Muzzammil Muttur – 2022 21 Potential Exam Questions Based on Past CIE Exam Papers
  • 22. © Muzzammil Muttur – 2022 22 1 (a) Write pseudocode for declaring a variable to be used. DECLARE VisitorName : STRING DECLARE dayNumber : INTEGER (b) Give an example of a constant you have used. AcessibleSpaces could have been used as a constant. It would then be declared and initialised at the start of the program. CONSTANT AcessibleSpaces : INTEGER AcessibleSpaces  5 2 List three variables in your solution and what they are used for. Variable 1:  FreeLocationFound  BOOLEAN data type  It is a flag used to indicate if a free location has been found for the requested day. Variable 2:  AccessibleSpaceNeeded  CHAR data type  It is used to store the answer to the question: “Is an accessible parking space needed? [Y/N]”  Answer to the question is either ‘Y’ or ‘N’. Variable 3:  dayNumber  INTEGER data type  It is used to store the user input for the day number when to make the booking (must be in the range 1 to 14 inclusive). 3 Give three examples of test data for day number (day on which to make parking space booking). Normal data: 1, 2, 5, 8, 10, 14 Abnormal data: 0, 15, three, $3.40 Borderline/Extreme data: 1, 14 (borderline and normal data); 0, 15 (borderline and abnormal data) 4 Describe the arrays you could have used in Task 1. Include the name, data type, use and sample data for each array. The two arrays used are: - Array 1: ParkingBookingName - Data type: STRING - SIZE: 280 - Used to store customer names when booking a parking space
  • 23. © Muzzammil Muttur – 2022 23 - Example: John Smith - Array 2: ParkingBookingCarNumber - Data type: STRING - SIZE: 280 - Used to store car license number when booking a parking space - Example: B1458 5 Show any validation check you have used in your solution REPEAT OUTPUT"Enter day number [1 to 14]: " INPUT dayNumber UNTIL dayNumber >= 1 AND dayNumber <= 14 6 Explain how your program checks that there is a free space (general parking space) for the day requested and identifies the slot number to be allocated. startingArrayID = ((dayNumber - 1) * 20) + 1 OUTPUT "Do you need an accesible parking space? [Y/N]" INPUT AccessibleSpaceNeeded FreeLocationFound  FALSE IF AccessibleSpaceNeeded = "Y" THEN Count  0 TotalAvailableParkingSpaces  20 REPEAT IF ParkingBookingName[startingArrayID + Count]  "Free" THEN FreeLocationFound  True ELSE Count = Count + 1 END IF UNTIL Count = TotalAvailableParkingSpaces OR FreeLocationFound = TRUE ELSEIF AccessibleSpaceNeeded = "N" THEN TotalAvailableParkingSpaces  15 Count  19 REPEAT IF ParkingBookingName[startingArrayID + Count] = "Free" THEN FreeLocationFound  True ELSE Count  Count - 1 END IF UNTIL Count = 5 OR FreeLocationFound = TRUE END IF 7 Explain how your program for Task 3 calculates the statistics for the number of general parking spaces used over the 14-day period. Any programming statements used in your answer must be fully explained. parkingCount  0 FOR dayNumber  1 TO 14 startingArrayID  ((dayNumber - 1) * 20) + 1
  • 24. © Muzzammil Muttur – 2022 24 FOR i  5 TO 19 IF ParkingBookingName[startingArrayID + i] <> "Free" THEN parkingCount  parkingCount + 1 END IF NEXT i NEXT dayNumber OUTPUT"Number of accessible spaces used on day ",dayNumber,": ", parkingCount 8 Comment on the efficiency of your design. The program has been made as efficient as possible with no block of code being uselessly repeated and duplicated. A single array of 280 locations has been used to store customer names for the whole 14-day period instead of 14 individual arrays. The program simply needs to move to the starting array location depending on the day chose. The same technique has been used to store customer license numbers. Additionally: you could be asked to write the pseudocode for Task 2 or Task 3 assuming that Task 1 or Task 2 have been completed.
  • 25. © Muzzammil Muttur – 2022 25 Program Code Microsoft Visual Basic Console Mode
  • 26. © Muzzammil Muttur – 2022 26 TASK 1 Module Module1 Sub Main() Dim dayNumber, startingArrayID As Integer Dim i, Count, choice As Integer Dim VisitorName, CarLicenseNumber As String Dim FreeLocationFound As Boolean Dim TotalAvailableParkingSlots As Integer Dim ParkingBookingName(280) As String Dim ParkingBookingCarNumber(280) As String For i = 1 To 280 ParkingBookingName(i) = "Free" ParkingBookingCarNumber(i) = "Free" Next Do Console.Clear() Console.WriteLine("Parking Space Booking System") Console.WriteLine("1. Make Booking") Console.WriteLine("2. Delete All Stored Data") Console.WriteLine("3. Exit") Console.WriteLine() Console.WriteLine("Enter your choice number: ") choice = Console.ReadLine If choice = 1 Then Do Console.WriteLine("Enter day number [1 to 14]: ") dayNumber = Console.ReadLine Loop Until dayNumber >= 1 And dayNumber <= 14 startingArrayID = ((dayNumber - 1) * 20) + 1 Count = 0 FreeLocationFound = False TotalAvailableParkingSlots = 20 Do If ParkingBookingName(startingArrayID + Count) = "Free" Then FreeLocationFound = True Else Count = Count + 1 End If Loop Until Count = TotalAvailableParkingSlots Or FreeLocationFound = True If FreeLocationFound = True Then Console.WriteLine("Enter visitor name: ") VisitorName = Console.ReadLine Console.WriteLine("Enter car license number: ") CarLicenseNumber = Console.ReadLine ParkingBookingName(startingArrayID + Count) = VisitorName
  • 27. © Muzzammil Muttur – 2022 27 ParkingBookingCarNumber(startingArrayID + Count) = CarLicenseNumber Console.WriteLine(startingArrayID + Count) Console.WriteLine("Parking space number booked: " , Count + 1) CONSOLE.READLINE() End If If FreeLocationFound = False Then Console.WriteLine("Sorry. No more free locations on selected day.") CONSOLE.READLINE() End If ElseIf choice = 2 Then For i = 1 To 280 ParkingBookingName(i) = "Free" ParkingBookingCarNumber(i) = "Free" Next End If Loop Until choice = 3 CONSOLE.READLINE() End Sub End Module
  • 28. © Muzzammil Muttur – 2022 28 TASK 2 Module Module1 Sub Main() Dim dayNumber, startingArrayID As Integer Dim i, Count, choice As Integer Dim VisitorName, CarLicenseNumber As String Dim FreeLocationFound As Boolean Dim parkingSlotNumber As Integer Dim AccessibleSpaceNeeded As Char Dim TotalAvailableParkingSpaces As Integer Dim ParkingBookingName(280) As String Dim ParkingBookingCarNumber(280) As String For i = 1 To 280 ParkingBookingName(i) = "Free" ParkingBookingCarNumber(i) = "Free" Next Do Console.Clear() Console.WriteLine("Parking Space Booking System") Console.WriteLine("1. Make Booking") Console.WriteLine("2. Delete All Stored Data") Console.WriteLine("3. Exit") Console.WriteLine() Console.WriteLine("Enter your choice number: ") choice = Console.ReadLine If choice = 1 Then Do Console.WriteLine("Enter day number [1 to 14]: ") dayNumber = Console.ReadLine Loop Until dayNumber >= 1 And dayNumber <= 14 startingArrayID = ((dayNumber - 1) * 20) + 1 Console.WriteLine("Do you need an accesible parking space? [Y/N]") AccessibleSpaceNeeded = Console.ReadLine FreeLocationFound = False If AccessibleSpaceNeeded = "Y" Then Count = 0 TotalAvailableParkingSpaces = 20 Do If ParkingBookingName(startingArrayID + Count) = "Free" Then FreeLocationFound = True Else Count = Count + 1 End If Loop Until Count = TotalAvailableParkingSpaces Or FreeLocationFound = True ElseIf AccessibleSpaceNeeded = "N" Then TotalAvailableParkingSpaces = 15 Count = 19 Do If ParkingBookingName(startingArrayID + Count) = "Free" Then FreeLocationFound = True Else
  • 29. © Muzzammil Muttur – 2022 29 Count = Count - 1 End If Loop Until Count = 4 Or FreeLocationFound = True End If If FreeLocationFound = True Then Console.WriteLine("Enter visitor name: ") VisitorName = Console.ReadLine Console.WriteLine("Enter car license number: ") CarLicenseNumber = Console.ReadLine ParkingBookingName(startingArrayID + Count) = VisitorName ParkingBookingCarNumber(startingArrayID + Count) = CarLicenseNumber Console.WriteLine(startingArrayID + Count) Console.WriteLine("Parking space number booked: " & Count + 1) CONSOLE.READLINE() End If If FreeLocationFound = False Then Console.WriteLine("Sorry. No more free locations on selected day.") CONSOLE.READLINE() End If ElseIf choice = 2 Then For i = 1 To 280 ParkingBookingName(i) = "Free" ParkingBookingCarNumber(i) = "Free" Next End If Loop Until choice = 3 CONSOLE.READLINE() End Sub End Module
  • 30. © Muzzammil Muttur – 2022 30 TASK 3 Module Module1 Sub Main() Dim dayNumber, startingArrayID As Integer Dim i, Count, choice, statisticsChoice, parkingCount As Integer Dim VisitorName, CarLicenseNumber As String Dim FreeLocationFound As Boolean Dim parkingSlotNumber As Integer Dim AccessibleSpaceNeeded As Char Dim TotalAvailableParkingSpaces As Integer Dim ParkingBookingName(280) As String Dim ParkingBookingCarNumber(280) As String For i = 1 To 280 ParkingBookingName(i) = "Free" ParkingBookingCarNumber(i) = "Free" Next Do Console.Clear() Console.WriteLine("Parking Space Booking System") Console.WriteLine("1. Make Booking") Console.WriteLine("2. Delete All Stored Data") Console.WriteLine("3. Show Statistics") Console.WriteLine("4. Exit") Console.WriteLine() Console.WriteLine("Enter your choice number: ") choice = Console.ReadLine If choice = 1 Then Do Console.WriteLine("Enter day number [1 to 14]: ") dayNumber = Console.ReadLine Loop Until dayNumber >= 1 And dayNumber <= 14 startingArrayID = ((dayNumber - 1) * 20) + 1 Console.WriteLine("Do you need an accesible parking space? [Y/N]") AccessibleSpaceNeeded = Console.ReadLine FreeLocationFound = False If AccessibleSpaceNeeded = "Y" Then Count = 0 TotalAvailableParkingSpaces = 20 Do If ParkingBookingName(startingArrayID + Count) = "Free" Then FreeLocationFound = True Else Count = Count + 1 End If Loop Until Count = TotalAvailableParkingSpaces Or FreeLocationFound = True ElseIf AccessibleSpaceNeeded = "N" Then TotalAvailableParkingSpaces = 15 Count = 19 Do If ParkingBookingName(startingArrayID + Count) = "Free" Then FreeLocationFound = True Else
  • 31. © Muzzammil Muttur – 2022 31 Count = Count - 1 End If Loop Until Count = 4 Or FreeLocationFound = True End If If FreeLocationFound = True Then Console.WriteLine("Enter visitor name: ") VisitorName = Console.ReadLine Console.WriteLine("Enter car license number: ") CarLicenseNumber = Console.ReadLine ParkingBookingName(startingArrayID + Count) = VisitorName ParkingBookingCarNumber(startingArrayID + Count) = CarLicenseNumber Console.WriteLine(startingArrayID + Count) Console.WriteLine("Parking space number booked: " & Count + 1) CONSOLE.READLINE() End If If FreeLocationFound = False Then Console.WriteLine("Sorry. No more free locations on selected day.") CONSOLE.READLINE() End If ElseIf choice = 2 Then For i = 1 To 280 ParkingBookingName(i) = "Free" ParkingBookingCarNumber(i) = "Free" Next 'show statistics ElseIf choice = 3 Then Console.Clear() Console.WriteLine("1 - Number of accessible spaces used on a specific day") Console.WriteLine("2 - Number of general spaces used on a specific day") Console.WriteLine("3 - Total number of parking spaces used on a specific day") Console.WriteLine("4 - Total number accessible spaces used on whole 14-day period") Console.WriteLine("5 - Total number general spaces used on whole 14-day period") Console.WriteLine("6 - Total number of parking spaces used on whole 14-day period") Console.WriteLine("7 - Back to main menu") Console.WriteLine() Console.WriteLine("Enter your choice number: ") statisticsChoice = Console.ReadLine If statisticsChoice = 1 Then Console.WriteLine("Enter day number [1-14]: ") dayNumber = Console.ReadLine startingArrayID = ((dayNumber - 1) * 20) + 1 parkingCount = 0 For i = 0 To 4 If ParkingBookingName(startingArrayID + i) <> "Free" Then parkingCount = parkingCount + 1 End If Next Console.Clear() Console.WriteLine("Number of accessible spaces used on day " & dayNumber & ": " & parkingCount) CONSOLE.READLINE() End If
  • 32. © Muzzammil Muttur – 2022 32 If statisticsChoice = 2 Then Console.WriteLine("Enter day number [1-14]: ") dayNumber = Console.ReadLine startingArrayID = ((dayNumber - 1) * 20) + 1 parkingCount = 0 For i = 5 To 19 If ParkingBookingName(startingArrayID + i) <> "Free" Then parkingCount = parkingCount + 1 End If Next Console.Clear() Console.WriteLine("Number of accessible spaces used on day " & dayNumber & ": " & parkingCount) CONSOLE.READLINE() End If If statisticsChoice = 3 Then Console.WriteLine("Enter day number [1-14]: ") dayNumber = Console.ReadLine startingArrayID = ((dayNumber - 1) * 20) + 1 parkingCount = 0 For i = 0 To 19 If ParkingBookingName(startingArrayID + i) <> "Free" Then parkingCount = parkingCount + 1 End If Next Console.Clear() Console.WriteLine("Number of accessible spaces used on day " & dayNumber & ": " & parkingCount) CONSOLE.READLINE() End If If statisticsChoice = 4 Then parkingCount = 0 For dayNumber = 1 To 14 startingArrayID = ((dayNumber - 1) * 20) + 1 For i = 0 To 4 If ParkingBookingName(startingArrayID + i) <> "Free" Then parkingCount = parkingCount + 1 End If Next Next Console.WriteLine("Number of accessible spaces used on day " & dayNumber & ": " & parkingCount) CONSOLE.READLINE() End If If statisticsChoice = 5 Then parkingCount = 0 For dayNumber = 1 To 14 startingArrayID = ((dayNumber - 1) * 20) + 1
  • 33. © Muzzammil Muttur – 2022 33 For i = 5 To 19 If ParkingBookingName(startingArrayID + i) <> "Free" Then parkingCount = parkingCount + 1 End If Next Next Console.WriteLine("Number of accessible spaces used on day " & dayNumber & ": " & parkingCount) CONSOLE.READLINE() End If If statisticsChoice = 6 Then parkingCount = 0 For dayNumber = 1 To 14 startingArrayID = ((dayNumber - 1) * 20) + 1 For i = 0 To 19 If ParkingBookingName(startingArrayID + i) <> "Free" Then parkingCount = parkingCount + 1 End If Next Next Console.WriteLine("Number of accessible spaces used on day " & dayNumber & ": " & parkingCount) Console.ReadLine() End If End If Loop Until choice = 4 CONSOLE.READLINE() End Sub End Module