Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

Department of Computer Science and Engineering

Shri Sai Institute of Technology, Aurangabad


(2023-2024)
Subject:- JPR
A Project Report
On
“Bus Reservation System ”
Submitted by :-
Sujal Sanjay Sonawane {2215420044}
Yash Kailash Puse {2215420055}

In partial fulfilment for the award of


Diploma in
Computer Science and Engineering

MAHARASHTRA STATE BOARD OF TECHNICAL


EDUCATION (MSBTE), MUMBAI, INDIA

CERTIFICATE
This is certified that, the project report entitled “Bus Reservation System”
Submitted by Sujal Sanjay Sonawane {Enroll. No. 2215420044}, Yash Kailash puse
{Enroll. No. 2215420055} Has completed as per the requirement of Maharashtra
State Board of Technical Education in partial fulfilment of Diploma in Computer
Science and Engineering.

Place: Aurangabad
Data: / /

Prof. Gaikwad V.M. Sign Sign


HOD-CW External Examiner Subject Teacher

Prof. Mr. P.S. TAYDE


Principal
Shri Sai Institute of Technology (Polytechnic),
Aurangabad

DECLARATION

We hereby declare that we have performed, completed and written the project
entitled “Bus Reservation System”. It has not previously submitted for the basis
of the award of any other degree or diploma or other similar title of his for any
other diploma/examining body or university to the best of knowledge and belief.

Place: Aurangabad
Date: / /

Sujal Sonawane
{Enroll. No. 2115420044}
Yash Kailash Puse
{Enroll. No. 2215420055}
INDEX
Sr. No. Content Page no.
1 About project
2 code
3 Output
ABOUT PROJECT

in this microproject we develope a Bus reservation system using java


programming. Bus Reservation and Ticketing System could be a straightforward
console based mostly application in Java. The feature of this easy application
includes adding passengers record, asking and viewing total records. so as to
feature a rider, the user must offer passenger’s name, destination, range of
passengers and discount range. alternative options embrace viewing offered
destination records, billings. This whole system isn't designed with the assistance
of Netbeans IDE.
CODE

import java.util.Scanner;

public class BusReservationSystem {


private static boolean[] seats = new boolean[10]; // Assuming 10 seats in
the bus

public static void main(String[] args) {


Scanner scanner = new Scanner(System.in);

while (true) {
System.out.println("1. Reserve a seat");
System.out.println("2. Cancel reservation");
System.out.println("3. View available seats");
System.out.println("4. Exit");
System.out.print("Enter your choice: ");
int choice = scanner.nextInt();
switch (choice) {
case 1:
reserveSeat();
break;
case 2:
cancelReservation();
break;
case 3:
viewAvailableSeats();
break;
case 4:
System.out.println("Exiting the program.");
System.exit(0);
break;
default:
System.out.println("Invalid choice. Please try again.");
}
}
}

private static void reserveSeat() {


Scanner scanner = new Scanner(System.in);

System.out.println("Enter seat number to reserve (1-10): ");


int seatNumber = scanner.nextInt();
if (seatNumber < 1 || seatNumber > 10) {
System.out.println("Invalid seat number.");
return;
}

if (seats[seatNumber - 1]) {
System.out.println("Seat " + seatNumber + " is already reserved.");
} else {
seats[seatNumber - 1] = true;
System.out.println("Seat " + seatNumber + " reserved
successfully.");
}
}

private static void cancelReservation() {


Scanner scanner = new Scanner(System.in);

System.out.println("Enter seat number to cancel reservation (1-10): ");


int seatNumber = scanner.nextInt();

if (seatNumber < 1 || seatNumber > 10) {


System.out.println("Invalid seat number.");
return;
}
if (seats[seatNumber - 1]) {
seats[seatNumber - 1] = false;
System.out.println("Reservation for seat " + seatNumber + "
canceled successfully.");
} else {
System.out.println("No reservation found for seat " + seatNumber +
".");
}
}

private static void viewAvailableSeats() {


System.out.println("Available seats:");
for (int i = 0; i < seats.length; i++) {
if (!seats[i]) {
System.out.print((i + 1) + " ");
}
}
System.out.println();
}
}
Output

You might also like