0478 22 Pre 2022 Pseudocode For All Tasks
0478 22 Pre 2022 Pseudocode For All Tasks
0478 22 Pre 2022 Pseudocode For All Tasks
IF IsSpaceAllotted THEN
PRINT "Your alloted parking space number is :" & CountSpaces
ELSE
PRINT "Sorry, No free space available for your selected day"
ENDIF
TASK 2 – FOR EXAM
IF ParkingSpaces[CountSpaces][Day] == "0"
AND IsSpaceAllotted == FALSE
THEN
PRINT "Please enter your Name :"
INPUT Name
PRINT "Please enter your LicenseNumber :"
INPUT LicenseNumber
IF IsSpaceAllotted THEN
PRINT "Your alloted parking space number is :" & CountSpaces
ELSE
PRINT "Sorry, No free space available for your selected day"
ENDIF
TASK 3 – FOR EXAM
REPEAT
CountStats <- 1
PRINT "Please select the below statistics (1 to 6) :"
PRINT "1. The number of accessible spaces used on any of the 14 days."
PRINT "2. The number of general spaces used on any of the 14 days."
PRINT "3. The total number of spaces used on any of the 14 days."
PRINT "4. The number of accessible spaces used in the whole 14-day period."
PRINT "5. The number of general spaces used in the whole 14-day period."
PRINT "6. The total number of spaces used in the whole 14-day period."
INPUT Statistics
PRINT "Please enter a day (1 to 14) :"
INPUT Day
2:
Count <- 0
FOR CountSpaces <- 6 to 20
IF ParkingSpaces[CountSpaces][Day] <> "0" THEN
Count <- Count + 1
ENDIF
NEXT CountSpaces
PRINT "The number of general parking spaces used : " & Count
3:
Count <- 0
FOR CountSpaces <- 1 to 20
IF ParkingSpaces[CountSpaces][Day] <> "0" THEN
Count <- Count + 1
ENDIF
NEXT CountSpaces
PRINT "The total number of parking spaces used : " & Count
4:
Count <- 0
FOR CountSpaces <- 1 to 5
FOR CountDays <- 1 to 14
IF ParkingSpaces[CountSpaces][Day] <> "0" THEN
Count <- Count + 1
ENDIF
NEXT CountSpaces
PRINT "The total number of accessible spaces used in the whole 14-day period.
" & Count
5:
Count <- 0
FOR CountSpaces <- 6 to 20
FOR CountDays <- 1 to 14
IF ParkingSpaces[CountSpaces][Day] <> "0" THEN
Count <- Count + 1
ENDIF
NEXT CountSpaces
PRINT "The number of general spaces used in the whole 14-day period." &
Count
6:
Count <- 0
FOR CountSpaces <- 1 to 20
FOR CountDays <- 1 to 14
IF ParkingSpaces[CountSpaces][Day] <> "0" THEN
Count <- Count + 1
ENDIF
NEXT CountSpaces
PRINT "The total number of spaces used in the whole 14-day period." & Count
ELSE
PRINT "Please enter a valid number from 1 to 6"
ENDIF
CountStats <- CountStats + 1
UNTIL Statistics > 0 AND Statistics < 7
COMPLETE PSEUDOCODE
//getting inputs
// Below code is the validation for Day input
REPEAT
PRINT "Please enter the day (1 to 14) :"
INPUT Day
IF Day <1 AND Day >14 THEN
PRINT "Please enter a valid day from 1 to 14"
ENDIF
UNTIL Day > 0 AND Day < 15
IF ParkingSpaces[CountSpaces][Day] == "0"
AND IsSpaceAllotted == FALSE
THEN
PRINT "Please enter your Name :"
INPUT Name
PRINT "Please enter your LicenseNumber :"
INPUT LicenseNumber
IF IsSpaceAllotted THEN
PRINT "Your alloted parking space number is :" & CountSpaces
ELSE
PRINT "Sorry, No free space available for your selected day"
ENDIF
REPEAT
CountStats <- 1
PRINT "Please select the below statistics (1 to 6) :"
PRINT "1. The number of accessible spaces used on any of the 14 days."
PRINT "2. The number of general spaces used on any of the 14 days."
PRINT "3. The total number of spaces used on any of the 14 days."
PRINT "4. The number of accessible spaces used in the whole 14-day period."
PRINT "5. The number of general spaces used in the whole 14-day period."
PRINT "6. The total number of spaces used in the whole 14-day period."
INPUT Statistics
PRINT "Please enter a day (1 to 14) :"
INPUT Day