0% found this document useful (0 votes)
36 views6 pages

Pre Release OCT 2022 CS 2210 Boyjonauth VB Pseudocode

This document contains pseudocode for a parking booking system with the following key details: 1) It includes data structures to store visitor names, license numbers, and the number of bookings per day. 2) The pseudocode has functions for booking a parking spot, generating statistics, and deleting all records. 3) Parking can be booked under general or accessible categories, with validation to check availability.

Uploaded by

Max Riddle
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views6 pages

Pre Release OCT 2022 CS 2210 Boyjonauth VB Pseudocode

This document contains pseudocode for a parking booking system with the following key details: 1) It includes data structures to store visitor names, license numbers, and the number of bookings per day. 2) The pseudocode has functions for booking a parking spot, generating statistics, and deleting all records. 3) Parking can be booked under general or accessible categories, with validation to check availability.

Uploaded by

Max Riddle
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Pre Release Material Oct 2022 Worked Out Solution Prepared by K Boyjonauth

Visual Basic programming Version (pseudocode on page 4)


Sub Main()
'task1
'Data structures
Dim name(280) As String 'name of visitor
Dim licensenum(280) As String ' license no of car
Dim daybooked(14) As Integer ' total booked for that day

'initialisation
For i = 1 To 14
daybooked(i) = 0
Next i
'constants
Const daymax = 14 ' the total no of days to book
Const parkmax = 20 ' max parking per day
Dim choice As Char
Dim daychosen, newparkno As Integer
Dim chosenpark As Integer
'input day of booking with validations
Do
Do

Console.WriteLine("Parking Booking System")


Console.WriteLine("Enter the day of booking")
daychosen = Console.ReadLine
If daychosen < 1 Or daychosen > daymax Then
Console.WriteLine("Invalid day number")
End If
Loop Until daychosen >= 1 And daychosen <= daymax
If daybooked(daychosen) >= parkmax Then
Console.WriteLine("Parking full")
Else
newparkno = daybooked(daychosen) + 1
Console.WriteLine("New Parking space allocated is: " & newparkno)
chosenpark = (daychosen - 1) * parkmax + daybooked(daychosen) + 1
Console.WriteLine("Enter The name of visitor:")
name(chosenpark) = Console.ReadLine
Console.WriteLine("Enter the license Number of Vehicle:")
licensenum(chosenpark) = Console.ReadLine

daybooked(daychosen) = daybooked(daychosen) + 1

End If
Console.WriteLine("Do you want to continue?")
choice = Console.ReadLine
Loop Until choice = "n"
Console.WriteLine("Do you want to delete all data of two week period?")
choice = Console.ReadLine
If choice = "y" Then
For i = 1 To daymax
daybooked(i) = 0
Next
For i = 1 To 280
name(i) = ""
licensenum(i) = ""
Next i
Console.WriteLine("All records deleted and reset successfully")
End If

Computer Science 2210 O Level Paper 2


Pre Release Material Oct 2022 Worked Out Solution Prepared by K Boyjonauth

End Sub
Sub Main()
'task2
Const parkmax = 20
Const generalmax = 15
Const daymax = 14
Dim name(280) As String
Dim licensenum(280) As String
Dim countgeneral(14) As Integer
Dim countaccessible(14) As Integer
Dim daycount, selectday, chosenpark, newparkno As Integer
Dim choice, choiceaccess As Char
'initialisation
For daycount = 1 To daymax
countgeneral(daycount) = 0
countaccessible(daycount) = 0
Next daycount
'input and choice of parking
Do
Console.WriteLine("Parking Booking System")
Do
Console.WriteLine("Enter the day number selected")
selectday = Console.ReadLine
Loop Until selectday >= 1 And selectday <= daymax
Console.WriteLine("Do you want to Accessible parkings or General
parkings")
Console.WriteLine("Press a for accessible or g for general parkings")
choiceaccess = Console.ReadLine
If choiceaccess = "g" Then
If countgeneral(selectday) < generalmax Then
chosenpark = ((selectday - 1) * parkmax) +
countgeneral(selectday) + 1
Console.WriteLine("Enter your Name")
name(chosenpark) = Console.ReadLine
Console.WriteLine("Enter the license Plate Number")
licensenum(chosenpark) = Console.ReadLine
newparkno = parkmax - countgeneral(selectday)
Console.WriteLine("Allocated Parking: " & newparkno)
countgeneral(selectday) = countgeneral(selectday) + 1

Else
Console.WriteLine("General parking booked")
End If
ElseIf choiceaccess = "a" Then
If countaccessible(selectday) < parkmax Then
chosenpark = ((selectday - 1) * parkmax) +
countaccessible(selectday) + 1
Console.WriteLine("Enter your Name")
name(chosenpark) = Console.ReadLine
Console.WriteLine("Enter the license Plate Number")
licensenum(chosenpark) = Console.ReadLine
countaccessible(selectday) = countaccessible(selectday) + 1
newparkno = countaccessible(selectday)
Console.WriteLine("Allocated Parking: " & newparkno)
End If
End If
Console.WriteLine("Do you want to continue:")
choice = Console.ReadLine

Computer Science 2210 O Level Paper 2


Pre Release Material Oct 2022 Worked Out Solution Prepared by K Boyjonauth

Loop Until choice = "n"


'task 3
Dim totalgeneral, totalaccess, totalparking As Integer
totalaccess = totalgeneral = totalparking = 0
Console.WriteLine("Enter the day on which statistics is to be generated")
selectday = Console.ReadLine
Console.WriteLine("Total Number of Accesible parking: " &
countaccessible(selectday))
Console.WriteLine("Total Number of General parking: " &
countgeneral(selectday))
Console.WriteLine("Total Number of parking: " & countaccessible(selectday) +
countgeneral(selectday))
For daycount = 1 To daymax
totalaccess = totalaccess + countaccessible(daycount)
totalgeneral = totalgeneral + countgeneral(daycount)
Next daycount
totalparking = totalaccess + totalgeneral
Console.WriteLine("Total Number of Accessible Parking for 14 days: " &
totalaccess)
Console.WriteLine("Total Number of General Parking for 14 days: " &
totalgeneral)
Console.WriteLine("Total number of parking booked for 14 days: " &
totalparking)
End Sub
End Module

Computer Science 2210 O Level Paper 2


Pre Release Material Oct 2022 Worked Out Solution Prepared by K Boyjonauth

Pseudocode Version
//program starts here
//Task1
DECLARE name:ARRAY[1:280] OF STRING
DECLARE licensenum:ARRAY[1:280] OF STRING
DECLARE daybooked:ARRAY[1:14] OF INTEGER
DECLARE index,daychosen,newparkno,chosenpark:INTEGER
DECLARE choice:CHAR
CONST daymax <-- 14
CONST parkmax <-- 20
FOR index <-- 1 to 14
daybooked[index] <-- 0
NEXT index
OUTPUT "PARKING BOOKING SYSTEM - BY MR K. BOYJONAUTH"
REPEAT
REPEAT
OUTPUT "Enter day of booking"
INPUT daychosen
IF daychosen <1 OR daychosen > daymax
THEN
OUTPUT "Invalid Day Number"
ENDIF
UNTIL daychosen >= 1 AND daychosen <=daymax
IF daybooked[daychosen] >=parkmax
THEN
OUTPUT "Parking Full"
ELSE
newparkno <-- daybooked[daychosen] + 1
OUTPUT "New parking space allocated: " & newparkno
chosenpark <-- (daychosen-1) * parkmax + daybooked(daychosen) +
1
OUTPUT "Enter Name of visitor"
INPUT Name[chosenpark]
OUTPUT "Enter lichence number of vehicle"
INPUT licensenum[chosenpark]
daybooked[daychosen] = daybooked[daychosen] + 1
ENDIF
OUTPUT "Do you want to continue? Press 'y' to continue or 'n' to stop"
INPUT choice
UNTIL choice = "n"
OUTPUT "Do you want to delete all the records of the two weeks?"
INPUT choice
IF choice = "y"
THEN
FOR index <-- 1 to 14
daybooked[index] <-- 0
NEXT index
FOR index <-- 1 to 280
name[index] <-- ""
licensenum[index] <-- ""
NEXT index
OUTPUT "All records successfully deleted"
ENDIF

Computer Science 2210 O Level Paper 2


Pre Release Material Oct 2022 Worked Out Solution Prepared by K Boyjonauth

//program starts here


//Task2
DECLARE name:ARRAY[1:280] OF STRING
DECLARE licensenum:ARRAY[1:280] OF STRING
DECLARE countgeneral:ARRAY[1:14] OF INTEGER
DECLARE countaccessible:ARRAY[1:14] OF INTEGER
DECLARE index,daychosen,newparkno,chosenpark:INTEGER
DECLARE choice,choiceaccess:CHAR
CONST daymax <-- 14
CONST parkmax <-- 20
CONST generalmax <-- 15
FOR index <-- 1 to 14
countgeneral[index] <-- 0
countaccessible[index] <--0
NEXT index
OUTPUT "PARKING BOOKING SYSTEM - BY MR K. BOYJONAUTH"
REPEAT
REPEAT
OUTPUT "Enter day of booking"
INPUT daychosen
IF daychosen <1 OR daychosen > daymax
THEN
OUTPUT "Invalid Day Number"
ENDIF
UNTIL daychosen >= 1 AND daychosen <=daymax
OUTPUT "Do you want Acceesible parking or General Parking?"
OUTPUT "Press 'a' for Accesible or 'g' for General Parking"
INPUT choiceaccess
if choiceaccess = "a"
THEN
IF countaccesible[daychosen] >=parkmax
THEN
OUTPUT "Accesible Parking Full"
ELSE
newparkno <-- countaccesible[daychosen] + 1
OUTPUT "New parking space allocated: " & newparkno
chosenpark <-- (daychosen-1) * parkmax +
countaccesible(daychosen) + 1
OUTPUT "Enter Name of visitor"
INPUT Name[chosenpark]
OUTPUT "Enter lichence number of vehicle"
INPUT licensenum[chosenpark]
countaccesible[daychosen] = countaccesible[daychosen] + 1
ELSEIF choiceaccess = "g"
THEN
IF countgeneral[daychosen] >=generalmax
THEN
OUTPUT "General Parking full"
ELSE
chosenpark <-- (daychosen-1) * parkmax +
countaccesible(daychosen) + 1
OUTPUT "Enter Name of visitor"
INPUT Name[chosenpark]
OUTPUT "Enter lichence number of vehicle"
INPUT licensenum[chosenpark]

Computer Science 2210 O Level Paper 2


Pre Release Material Oct 2022 Worked Out Solution Prepared by K Boyjonauth

newparkno = parkmax - countgeneral[daychosen]


OUTPUT "New parking space allocated: " & newparkno
ENDIF
ENDIF

OUTPUT "Do you want to continue? Press 'y' to continue or 'n' to stop"
INPUT choice
UNTIL choice = "n"

//TASK 3

DECALRE totalgeneral,totalaccess,totalparking:INTEGER
totalaccess <-- 0
totalgeneral <-- 0
REPEAT
OUTPUT "Enter day on which statistics is to be generated"
INPUT daychosen
IF daychosen <1 OR daychosen > daymax
THEN
OUTPUT "Invalid Day Number"
ENDIF
UNTIL daychosen >= 1 AND daychosen <=daymax
OUTPUT "Total number of accesible Parking: " & countaccesible[daychosen]
OUTPUT "Total number of general Parking: " & countgeneral[daychosen]
OUTPUT "Total number of parking on this day:"
&(countaccesible[daychosen]+countgeneral[daychosen]
FOR index = 1 to daymax
totalaccess <-- totalaccess + countaccesible[daycount]
totalgeneral <--totalgeneral + countgeneral[daycount]
NEXT index
totalparking <-- totalaccess + totalgeneral
OUTPUT "Total number of accessible parking for 14 days:" & totalaccess
OUTPUT "Total number of general parking for 14 days: " & totalgeneral
OUTPUT "Total number of parking spaces booked for 14 days:" & totalparking

Computer Science 2210 O Level Paper 2

You might also like