0% found this document useful (0 votes)
93 views3 pages

Algorithm For Parking Management System

The document outlines an algorithm for a Parking Management System, detailing steps for initialization, loading current status, displaying available slots, and handling user input for vehicles entering and leaving. It includes procedures for updating slot statuses and saving the changes to a CSV file. The system assumes a total of 5 slots, initially empty, and provides sample execution scenarios demonstrating its functionality.

Uploaded by

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

Algorithm For Parking Management System

The document outlines an algorithm for a Parking Management System, detailing steps for initialization, loading current status, displaying available slots, and handling user input for vehicles entering and leaving. It includes procedures for updating slot statuses and saving the changes to a CSV file. The system assumes a total of 5 slots, initially empty, and provides sample execution scenarios demonstrating its functionality.

Uploaded by

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

Algorithm for Parking Management System

Step 1: Initialization

1. Check if parking.csv exists.


2. If not, create the file with:
o A header: Slot,Status
o Rows from 1 to TOTAL_SLOTS, all marked as 'Empty'.

Step 2: Load Current Parking Status

3. Open parking.csv and read all rows.


4. Store the slot data in a list (each slot has a number and status).

Step 3: Display Available Slots

5. Count and display all slots where status is 'Empty'.

Step 4: User Input

6. Ask user to enter:


o Number of vehicles entering.
o Number of vehicles leaving.

Step 5: Update for Entering Vehicles

7. Loop through the parking slots.


8. For each 'Empty' slot, mark it as 'Occupied' until the entering count is fulfilled.
9. If not enough empty slots, inform the user.

Step 6: Update for Leaving Vehicles

10. Loop through the parking slots.


11. For each 'Occupied' slot, mark it as 'Empty' until the leaving count is fulfilled.
12. If not enough occupied slots, inform the user.

Step 7: Save Updated Status

13. Overwrite parking.csv with the updated slot statuses.

Step 8: Repeat or Exit

14. Ask user if they want to continue.


15. If yes, go back to Step 2.
16. If no, exit the program.
Assumptions

 Total slots = 5
 Initial state: all slots are empty.

Sample Execution

✅ First Run

Available slots: [1, 2, 3, 4, 5]

Vehicles entering: 3
Vehicles leaving: 0
3 vehicle(s) entered.
Continue? (y/n): y

CSV after this step:

Slot,Status
1,Occupied
2,Occupied
3,Occupied
4,Empty
5,Empty

✅ Second Run

Available slots: [4, 5]

Vehicles entering: 2
Vehicles leaving: 1
2 vehicle(s) entered.
1 vehicle(s) left.
Continue? (y/n): y

CSV after this step:

Slot,Status
1,Empty
2,Occupied
3,Occupied
4,Occupied
5,Occupied
✅ Third Run

Available slots: [1]

Vehicles entering: 2
Vehicles leaving: 1
Only 1 vehicles entered. No more free slots.
1 vehicle(s) left.
Continue? (y/n): n

CSV after this step:

Slot,Status
1,Occupied
2,Empty
3,Occupied
4,Occupied
5,Occupied

You might also like