Coders Packet

Car Reservation System by java

By Kunal Kanti Saha

This program is a simple car reservation system which can reserve a car and cancel the reservation of the car.

The given Java code represents a simple Car Reservation System. People can view cars details, can reserve a car, cancel a reservation and also view all reservations. If there work is done they exit the system.

The main component of the program is:

  1. private static boolean[] reserve: It is an array of boolean values to represent the reservation status of each car. The index of the array is the car's number (1 to 10). The value at that index is true if the car is reserved and otherwise it is false.
  2. private static Scanner sc : sc is the object by which people can enter the required input.

 

The main function of the program is:

  1. CarDetails(): This method displays the cars Name and Price corresponding to its number.
  2. CarReservation(): This method allows users to reserve a car by selecting the car number. If the chosen car is available (not reserved), the reservation is successful, and the reservation status for that car is updated to true. If the car is already reserved, the user is informed that
    that car is already reserved.
  3. ReservationCancel(): This method allows users to cancel a previously made reservation by selecting the car number. If the chosen car is currently reserved, the reservation is canceled by updating the reservation status to false. If the car is not reserved, the user is informed that
    that car is not currently reserved.
  4. ReservationsDetails(): This method displays all the cars that are currently reserved.
  5. The main method: The main function is the entry point of the program from where the main execution of the program starts. It displays a menu of options where the user takes their choice. Based on the user's selection, the corresponding method is called to perform the task.

The program will keep running until user gives the input 5 (Exit). Afterthat the programs will end.

*note: The program does not have any current database so that the data of reservation will delete after the program ends.

 
 

Download Complete Code

Comments

No comments yet

Download Packet

Reviews Report

Submitted by Kunal Kanti Saha (kunal0010)

Download packets of source code on Coders Packet