cd C:\Bus_reservation\buss_reservation.java\srcjavac Main.javaThis will compile Main.java and create the necessary .class files (Main.class, Bus.class, and Passenger.class).
java MainOnce the program starts, you'll see a menu with these options:
==== Bus Reservation System ====
1. View All Buses
2. View Available Seats
3. Book a Seat
4. Cancel a Seat
5. Display All Bookings
6. Exit
-
View All Buses (Option 1)
- Shows Bus101 (10 seats) and Bus102 (15 seats)
-
Book a Seat (Option 3)
- Enter Bus ID:
Bus101 - Enter Seat Number:
1 - Enter Passenger Name:
John Doe - Enter Phone Number:
1234567890
- Enter Bus ID:
-
View Available Seats (Option 2)
- Enter Bus ID:
Bus101 - Shows remaining available seats
- Enter Bus ID:
-
Display All Bookings (Option 5)
- Enter Bus ID:
Bus101 - Shows all booked seats with passenger details
- Enter Bus ID:
-
Cancel a Seat (Option 4)
- Enter Bus ID:
Bus101 - Enter Seat Number:
1
- Enter Bus ID:
-
Exit (Option 6)
- Exits the program
- Java Development Kit (JDK) 8 or higher must be installed
- Make sure
javacandjavacommands are available in your system PATH
If you get "javac is not recognized":
- Install JDK from https://www.oracle.com/java/technologies/downloads/
- Add JDK's bin directory to your system PATH
If you get compilation errors:
- Make sure you're in the correct directory:
C:\Bus_reservation\buss_reservation.java\src - Ensure Main.java file exists and is not corrupted
Bus_reservation/
└── buss_reservation.java/
└── src/
├── Main.java (contains Main, Bus, and Passenger classes)
├── Main.class (generated after compilation)
├── Bus.class (generated after compilation)
└── Passenger.class (generated after compilation)