Skip to content
  • SiteMap
  • Our Services
  • Frequently Asked Questions (FAQ)
  • Support
  • About Us

UpdateGadh

Update Your Skills.

  • Home
  • Projects
    •  Blockchain projects
    • Python Project
    • Data Science
    •  Ai projects
    • Machine Learning
    • PHP Project
    • React Projects
    • Java Project
    • SpringBoot
    • JSP Projects
    • Java Script Projects
    • Code Snippet
    • Free Projects
  • Tutorials
    • Ai
    • Machine Learning
    • Advance Python
    • Advance SQL
    • DBMS Tutorial
    • Data Analyst
    • Deep Learning Tutorial
    • Data Science
    • Nodejs Tutorial
  • Blog
  • Contact us
  • Toggle search form
Hotel Booking System in Java with Source Code - Hotel Booking System

Hotel Booking System in Java with Source Code

Posted on October 3, 2024October 3, 2024 By Rishabh saini No Comments on Hotel Booking System in Java with Source Code

Hotel Booking System in Java

Managing hotel reservations can be a complex and time-consuming process, but with a Hotel Booking System built in Java, the process becomes simpler, more efficient, and organized. This Java-based application is designed to handle room reservations, guest details, and manage bookings seamlessly, making it ideal for small inns, guesthouses, and boutique hotels.

Table of Contents

  • Hotel Booking System in Java
    • Key Features 🌟
    • Getting Started 🚀
      • Prerequisites
    • Step-by-Step Setup
    • Code
    • Explanation of the System
    • Running the Application
    • Usage 📋

Key Features 🌟

  1. Reserve a Room
    The system allows the user to easily reserve rooms by entering guest details, selecting a room number, and providing contact information. It tracks the reservation details and stores them securely in a database.
  2. View Reservations
    This feature provides a clear overview of all current bookings. Users can see guest names, room numbers, contact details, and reservation dates. It’s an efficient way to keep track of who’s staying and for how long.
  3. Edit Reservation Details
    The system is flexible, allowing users to update existing reservation details. Whether it’s a name change or a room switch, editing reservations is hassle-free.
  4. Delete Reservations
    Old or canceled bookings can easily be deleted from the system, ensuring that the reservation list stays up-to-date and clutter-free.

PHP PROJECT:- CLICK HERE


Getting Started 🚀

Here’s a simple guide to setting up the Hotel Booking System on your local machine.

Prerequisites

  • Java Development Kit (JDK): Ensure you have JDK installed to compile and run the Java application.
  • MySQL Database: The system requires a MySQL database to store and manage reservation data.
  • MySQL Connector/J: This is necessary for Java to communicate with the MySQL database.
https://updategadh.com/final-year-projects/final-year-project-ideas-2/

Step-by-Step Setup

If you’d like a Hotel Reservation System in Java without using a database, we can store the data in memory using Java’s ArrayList or other collection classes. This approach simplifies the code and allows you to manage hotel reservations without the complexity of setting up and managing a database.

Here’s a simplified version of the Hotel Booking System that uses an ArrayList to store reservations:

Code

import java.util.ArrayList;
import java.util.Scanner;

class Reservation {
    private int id;
    private int roomNumber;
    private String guestName;
    private String contactInfo;
    private String checkInDate;
    private String checkOutDate;

    public Reservation(int id, int roomNumber, String guestName, String contactInfo, String checkInDate, String checkOutDate) {
        this.id = id;
        this.roomNumber = roomNumber;
        this.guestName = guestName;
        this.contactInfo = contactInfo;
        this.checkInDate = checkInDate;
        this.checkOutDate = checkOutDate;
    }

    // Getters and setters
    public int getId() { return id; }
    public int getRoomNumber() { return roomNumber; }
    public String getGuestName() { return guestName; }
    public void setGuestName(String guestName) { this.guestName = guestName; }
    public String getContactInfo() { return contactInfo; }
    public void setContactInfo(String contactInfo) { this.contactInfo = contactInfo; }
    public String getCheckInDate() { return checkInDate; }
    public String getCheckOutDate() { return checkOutDate; }

    @Override
    public String toString() {
        return "Reservation ID: " + id + 
               ", Room Number: " + roomNumber + 
               ", Guest: " + guestName + 
               ", Contact: " + contactInfo + 
               ", Check-in: " + checkInDate + 
               ", Check-out: " + checkOutDate;
    }
}

public class HotelReservationSystem {
    private ArrayList<Reservation> reservations;
    private int nextReservationId;

    public HotelReservationSystem() {
        reservations = new ArrayList<>();
        nextReservationId = 1;
    }

    // Method to add a new reservation
    public void addReservation(int roomNumber, String guestName, String contactInfo, String checkInDate, String checkOutDate) {
        Reservation reservation = new Reservation(nextReservationId, roomNumber, guestName, contactInfo, checkInDate, checkOutDate);
        reservations.add(reservation);
        nextReservationId++;
        System.out.println("Reservation successfully added!");
    }

    // Method to view all reservations
    public void viewReservations() {
        if (reservations.isEmpty()) {
            System.out.println("No reservations found.");
        } else {
            for (Reservation reservation : reservations) {
                System.out.println(reservation);
            }
        }
    }

    // Method to update an existing reservation
    public void updateReservation(int id, String guestName, String contactInfo) {
        for (Reservation reservation : reservations) {
            if (reservation.getId() == id) {
                reservation.setGuestName(guestName);
                reservation.setContactInfo(contactInfo);
                System.out.println("Reservation successfully updated!");
                return;
            }
        }
        System.out.println("Reservation not found.");
    }

    // Method to delete a reservation
    public void deleteReservation(int id) {
        for (Reservation reservation : reservations) {
            if (reservation.getId() == id) {
                reservations.remove(reservation);
                System.out.println("Reservation successfully deleted!");
                return;
            }
        }
        System.out.println("Reservation not found.");
    }

    // Main menu for interacting with the system
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        HotelReservationSystem system = new HotelReservationSystem();

        while (true) {
            System.out.println("\nHotel Reservation System Menu:");
            System.out.println("1. Add a Reservation");
            System.out.println("2. View All Reservations");
            System.out.println("3. Update a Reservation");
            System.out.println("4. Delete a Reservation");
            System.out.println("5. Exit");

            System.out.print("Enter your choice: ");
            int choice = scanner.nextInt();
            scanner.nextLine();  // Consume newline

            switch (choice) {
                case 1:
                    // Add a reservation
                    System.out.print("Enter Room Number: ");
                    int roomNumber = scanner.nextInt();
                    scanner.nextLine();
                    System.out.print("Enter Guest Name: ");
                    String guestName = scanner.nextLine();
                    System.out.print("Enter Contact Information: ");
                    String contactInfo = scanner.nextLine();
                    System.out.print("Enter Check-in Date (YYYY-MM-DD): ");
                    String checkInDate = scanner.nextLine();
                    System.out.print("Enter Check-out Date (YYYY-MM-DD): ");
                    String checkOutDate = scanner.nextLine();
                    system.addReservation(roomNumber, guestName, contactInfo, checkInDate, checkOutDate);
                    break;
                case 2:
                    // View all reservations
                    system.viewReservations();
                    break;
                case 3:
                    // Update a reservation
                    System.out.print("Enter Reservation ID to update: ");
                    int idToUpdate = scanner.nextInt();
                    scanner.nextLine();
                    System.out.print("Enter New Guest Name: ");
                    String newGuestName = scanner.nextLine();
                    System.out.print("Enter New Contact Information: ");
                    String newContactInfo = scanner.nextLine();
                    system.updateReservation(idToUpdate, newGuestName, newContactInfo);
                    break;
                case 4:
                    // Delete a reservation
                    System.out.print("Enter Reservation ID to delete: ");
                    int idToDelete = scanner.nextInt();
                    system.deleteReservation(idToDelete);
                    break;
                case 5:
                    // Exit
                    System.out.println("Exiting...");
                    System.exit(0);
                    break;
                default:
                    System.out.println("Invalid choice. Please try again.");
            }
        }
    }
}
Hotel Booking System in Java
Hotel Booking System in Java
Hotel Booking System in Java
Hotel Booking System in Java
Hotel Booking System in Java
Hotel Booking System in Java
Hotel Booking System in Java
Hotel Booking System in Java
Hotel Booking System in Java

New Project :-https://www.youtube.com/@Decodeit2

Explanation of the System

  • Reservation Class: Holds information about a single reservation, such as the room number, guest details, and dates.
  • HotelReservationSystem Class: Contains an ArrayList to store the reservations and provides methods to add, view, update, and delete reservations.
  • Main Menu: Allows users to interact with the system using a menu-driven interface to add new reservations, view all reservations, update, or delete them.

Running the Application

  1. Copy and paste the code into a Java file (HotelReservationSystem.java).
  2. Compile and run the program:
   javac HotelReservationSystem.java
   java HotelReservationSystem

Once the program runs, you’ll be presented with a menu where you can choose to add a reservation, view all reservations, update a reservation, or delete a reservation.

Feel free to modify and expand the project as per your requirements!


Usage 📋

After running the application, the system will prompt you with a menu to choose the operation you want to perform. The options are:

  • Make a new reservation
  • View all reservations
  • Edit existing reservations
  • Delete reservations
  • Exit the system

Post Views: 1,082
code Snippets Tags:hotel booking system, hotel management system, hotel management system in java, hotel management system project in react, hotel management system project in spring boot, hotel management system spring boot, hotel order booking system in java, hotel reservation system design, hotel reservation system in java, hotel room booking system in java, jsp and mysql project on hotel booking system

Post navigation

Previous Post: Top 10 Final Year Project Ideas for Java
Next Post: Social Media Data Automating with Python

More Related Articles

ATM Simulator in Python with Source Code - ATM Simulator in Python with Source Code ATM Simulator in Python with Source Code code Snippets
Book Library in JavaScript With Free Code - Book Library Book Library in JavaScript With Free Code code Snippets
Bill Management System in Python Free Source Code - Bill Management Bill Management System in Python Free Source Code code Snippets

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

You may also like

  1. Supply Chain Management PHP and CSS
  2. Online Shopping System using PHP, MySQL with Free Source Code
  3. F1 Race Road Game in Python Free Source Code
  4. Supplier Management System in Java with Free Code
  5. Create Address Book in Python with Source Code
  6. Contact Management in Python with Source Code

Most Viewed Posts

  1. Top Large Language Models in 2025
  2. Online Shopping System using PHP, MySQL with Free Source Code
  3. login form in php and mysql , Step-by-Step with Free Source Code
  4. Flipkart Clone using PHP And MYSQL Free Source Code
  5. News Portal Project in PHP and MySql Free Source Code
  6. User Login & Registration System Using PHP and MySQL Free Code
  7. Top 10 Final Year Project Ideas in Python
  8. Online Bike Rental Management System Using PHP and MySQL
  9. E learning Website in php with Free source code
  10. E-Commerce Website Project in Java Servlets (JSP)
  • AI
  • ASP.NET
  • Blockchain
  • ChatCPT
  • code Snippets
  • Collage Projects
  • Data Science Project
  • Data Science Tutorial
  • DBMS Tutorial
  • Deep Learning Tutorial
  • Final Year Projects
  • Free Projects
  • How to
  • html
  • Interview Question
  • Java Notes
  • Java Project
  • Java Script Notes
  • JAVASCRIPT
  • Javascript Project
  • JSP JAVA(J2EE)
  • Machine Learning Project
  • Machine Learning Tutorial
  • MySQL Tutorial
  • Node.js Tutorial
  • PHP Project
  • Portfolio
  • Python
  • Python Interview Question
  • Python Projects
  • PythonFreeProject
  • React Free Project
  • React Projects
  • Spring boot
  • SQL Tutorial
  • TOP 10
  • Uncategorized
  • Online Examination System in PHP with Source Code
  • AI Chatbot for College and Hospital
  • Job Portal Web Application in PHP MySQL
  • Online Tutorial Portal Site in PHP MySQL — Full Project with Source Code
  • Online Job Portal System in JSP Servlet MySQL

Most Viewed Posts

  • Top Large Language Models in 2025 (8,612)
  • Online Shopping System using PHP, MySQL with Free Source Code (5,211)
  • login form in php and mysql , Step-by-Step with Free Source Code (4,866)

Copyright © 2026 UpdateGadh.

Powered by PressBook Green WordPress theme