Pre Release OCT 2022 CS 2210 Boyjonauth VB Pseudocode
Pre Release OCT 2022 CS 2210 Boyjonauth VB Pseudocode
'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
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
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
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
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