Skip to content

codehelping.com

No. 1 For Project and Interview

  • Home
  • Projects
  • Blog
  • Contact Us

Complete Hotel Management System Project in Java with Source Code

Posted on July 13, 2025July 13, 2025 By Omkar Pathak No Comments on Complete Hotel Management System Project in Java with Source Code
Blog, Java Project, Project

In this blog, we’ll walk through a complete hotel management system project in Java. This console-based program simulates the operations of a hotel named Hotel Transylvania. It handles check-ins, check-outs, food orders, customer information, and bill generation, all managed via simple Java classes and arrays.

Complete Hotel Management System Project in Java with Source Code

What This Project Does

This project is a simulation of a hotel front desk system. It allows the hotel to:

  • Allot rooms to customers
  • Maintain customer information
  • Let guests order food
  • Generate bills for their stay and food
  • Track room availability

The program uses Java’s OOP concepts such as classes, inheritance, exception handling, arrays, and calendar-based date manipulation.

Project Structure & Classes

This project uses multiple classes to divide functionality clearly:

WrongInputException

A custom exception class to handle wrong menu inputs or invalid choices. If the user selects an option that isn’t on the menu (like choice 9), this exception will be triggered and handled gracefully.

Customer

This class stores customer details such as name, address, and contact number. It also has a method display_Customer() to show this information on the console.

Food

This class manages the food menu and billing system. It stores:

  • A list of food items (like Bread Butter, Tea, Coffee)
  • Prices for each item
  • An array that keeps track of how many items the customer ordered

When food_billing() is called, it displays the quantity and price of each ordered item, and calculates the total.

Room

This class represents a hotel room. It contains:

  • Customer information (Customer object)
  • Room number
  • A calendar object to track check-in date
  • A Food object to manage food orders
  • Room and food pricing

Its key methods include:

  • display() – shows customer and room info
  • billing(long days) – calculates the total bill for room stay and food (with 19% tax)

Hotel (Main Class)

This is the main driver class with the main() method. It creates an array of 20 Room objects (20 total rooms) and manages the entire hotel operation using a while loop and a switch menu.

Step-by-Step Flow of the Program

Let’s now walk through how the program actually runs when you execute it:

Step 1: Welcome Screen

The program starts by printing the hotel name, contact number, and the current date. Then it shows the menu options:

mathematicaCopyEditEnter your choice: 
1. Check In
2. Customer Info
3. Order Food
4. Check Out
5. Exit

Step 2: Check-In Process (Option 1)

  • The system checks if rooms are available.
  • Displays the room numbers that are vacant.
  • Asks the user to select a room number.
  • Takes customer’s name, address, contact number.
  • Asks for the check-in date.
  • Stores all this information in a Room object.

If the room number is invalid or already taken, it shows appropriate messages using exception handling.

Step 3: View Customer Info (Option 2)

  • Asks for a room number.
  • If the room is occupied, it displays customer details.
  • If vacant, it says “Room Is Vacant!”.

Step 4: Order Food (Option 3)

  • Asks for your room number.
  • Displays a list of food items with prices.
  • You select the food item index and quantity.
  • It updates the food order for your room.

If you enter an invalid choice (e.g., item 9), the WrongInputException is thrown and a message is shown.

Step 5: Check-Out Process (Option 4)

  • Asks for your room number.
  • Displays your info and check-in date.
  • Takes the current date for check-out.
  • Calculates how many days you stayed.
  • Calls the billing() function, which:
    • Multiplies stay days by room rate (₹1500/day)
    • Adds food charges
    • Calculates 19% tax
    • Shows a well-formatted final bill
  • After billing, it frees the room for other customers.

Step 6: Exit (Option 5)

  • The loop stops and the program ends.

Billing Logic

The billing in this project is simple but realistic:

  • Base charge per day: ₹1500
  • Food charges are calculated from the quantity and item price
  • Tax: 19% on total amount (room + food)
  • All prices and details are shown in a neat bill format

Hotel Management System Project in Java with Source Code

import java.util.Calendar;
import java.util.Date;
import java.util.Scanner;
class WrongInputException extends Exception
{
	String str1=new String();
	WrongInputException(String str)
	{
		str1=str;
	}
	public String toString()
	{
		return("WrongInputException -> "+str1);
	}
}
class Customer
{
	String name=new String();
	String add=new String();
	String no=new String();
	void display_Customer()
	{
		System.out.println("Name- "+name);
		System.out.println("Address- "+add);
		System.out.println("Contact No.- "+no);
    }
}
class Food
{
	static final String b[]=new String[6];
	static final int rate[]=new int[6];
	int f[]=new int[6];
	int i;
	Food()
	{
		for(i=0;i<6;i++)
		{
			f[i]=0;
		}
		for(i=0;i<6;i++)
		{
			b[i]=new String();
		}
		b[0]="Bread Butter        ";
		b[1]="Bread Omelet        ";
		b[2]="Coffee              ";
		b[3]="Tea                 ";
		b[4]="Mineral Water       ";
		b[5]="Ice Cream           ";
		rate[0]=40;
		rate[1]=55;
		rate[2]=35;
		rate[3]=30;
		rate[4]=25;
		rate[5]=50;
	
	}
	void food_billing()
	{
		System.out.println(" Item                   Quantity          Price");
		for(i=0;i<6;i++)
		{
			if(f[i]!=0)
			{
				System.out.println(b[i]+"    "+f[i]+"                 "+(rate[i]*f[i]));
			}
		}
		System.out.println("-----------------------------------------------------------------------------");
	}
}
class Room
{
	static int vacant=20;
	int room_no;
	Customer c=new Customer();
	Calendar in=Calendar.getInstance();
	final int base=1500;
	Food food=new Food();
	int food_bill=0;
	double tax;
	double total_bill;
	
	void display()
	{
		System.out.println("Room No.- "+room_no);
		c.display_Customer();
	}
	void billing(long x)
	{	
		int i;
		for(i=0;i<6;i++)
		{
			food_bill+=food.f[i]*Food.rate[i];
		}
		tax=0.19*((base*x)+food_bill);
		total_bill=(base*x)+food_bill+tax;
		Date d1=new Date();
		System.out.println("-----------------------------------------------------------------------------");
		System.out.println("-----------------------------------------------------------------------------");
		System.out.println("                            Hotel Transylvania                               ");
		System.out.println("                               New Delhi                                     ");
		System.out.println("                          +1234567890,9876543210                             \n");
		System.out.println("                                                   Dated: "+d1+"\n");
		System.out.println("Customer Details:\n");
		c.display_Customer();
		System.out.println("No. of Days = "+x);
		System.out.println("------------------------------Room Billing-----------------------------------");
		System.out.println("Base Price For "+x+" Days          ---------- "+(base*x)+" Rs.");
		System.out.println("------------------------------Food Billing-----------------------------------");
		food.food_billing();
		System.out.println("Total Food Price               ---------- "+food_bill+" Rs.");
		System.out.println("Total Tax (19%)                ---------- "+tax+" Rs.");
		System.out.println("Total Bill                     ---------- "+total_bill+" Rs.");
		System.out.println("-----------------------------------------------------------------------------");
		System.out.println("-----------------------------------------------------------------------------");
	}
}
public class Hotel 
{
	public static void main(String args[])
	{
		WrongInputException ex=new WrongInputException("Invalid Choice!");
		Room r[]=new Room[20];
		int i;
		for(i=0;i<20;i++)
		{
			r[i]=new Room();
		}
		int ch;
		Date d=new Date();
		System.out.println("                            Hotel Transylvania                               ");
		System.out.println("                               New Delhi                                     ");
		System.out.println("                          +1234567890,9876543210                             \n");
		System.out.println("                                                   Dated: "+d+"\n");
		Scanner scan=new Scanner(System.in);
		int x1=1;
		while(x1!=0)
		{
		System.out.println("-----------------------------------------------------------------------------");
		System.out.println("Enter your choice: \n1.Check In\n2.Customer Info\n3.Order Food\n4.Check Out\n5.Exit");
		System.out.println("-----------------------------------------------------------------------------");
		ch=scan.nextInt();
		switch(ch)
		{
		case 1:	if(Room.vacant==0)
				{
					System.out.println("Rooms Not Available!");
					System.out.println("Thanks for Your Visit!");
					break;
				}
		        System.out.println("No. of Rooms Vacant = "+Room.vacant);
				System.out.println("Rooms Vacant:");
				for(i=0;i<20;i++)
				{	
					if(r[i].room_no!=i+1)
					{
						System.out.println("              Room No."+(i+1));
					}
				}
				System.out.println("Enter the Room No. to be Alloted");
				System.out.println("             OR                 ");
				System.out.println("To go back to Main Menu--Enter 0");
				int allot=scan.nextInt();
				scan.nextLine();
				if(allot==0)
				{
					break;
				}
				else if(allot>20)
					{
						try
						{
							throw ex;
						}
						catch(WrongInputException e)
						{
							System.out.println(e);
							break;
						}
					}
					else
					{
						if(r[allot-1].room_no==allot)
						{
							System.out.println("Room Not Available");
							break;
						}
						r[allot-1].room_no=allot;
						Customer c1=new Customer();
						System.out.println("Enter the Customer Name");
						c1.name=scan.nextLine();
						System.out.println("Enter the Address");
						c1.add=scan.nextLine();
						System.out.println("Enter the Contact No.");
						c1.no=scan.nextLine();
						r[allot-1].c=c1;
						Calendar date=Calendar.getInstance();
						System.out.println("Enter the Date Today in Numerical Form:");
						System.out.println("Day:");
						int d3=scan.nextInt();
						System.out.println("Month:");
						int d2=scan.nextInt();
						System.out.println("Year:");
						int d1=scan.nextInt();
						date.set(d1,d2,d3);
						r[allot-1].in=date;
						System.out.println("Room No. "+allot+" Alloted!");
						Room.vacant--;
					}
					break;
				
		case 2: System.out.println("Enter Room No. For Information");
				int info=scan.nextInt();
				if(r[info-1].room_no!=info)
				{
					System.out.println("Room Is Vacant!");
					break;
				}
				r[info-1].display();
				break;
		case 3: System.out.println("Enter your Room No.");
				int no=scan.nextInt();
				if(r[no-1].room_no!=no)
				{
					System.out.println("Room Is Vacant!");
					break;
				}
			    System.out.println("Choose the Index You Want to order:");
			    System.out.println("   Item              Price");
				for(i=0;i<6;i++)
				{
					System.out.println((i+1)+". "+Food.b[i]+Food.rate[i]+" Rs.");
				}
				int ch1=scan.nextInt();
				try
				{
					if((ch1<1)||(ch1>6))
					{
						throw ex;
					}
		        }
				catch(WrongInputException e)
				{
					System.out.println(e);
					break;
				}
				System.out.println("Enter the Quantity");
				int quan=scan.nextInt();
				r[no-1].food.f[ch1-1]+=quan;
				System.out.println("Item Ordered Successfully");
				break;
				
		case 4: System.out.println("Enter Your Room No.");
				int unallot=scan.nextInt();
				if(r[unallot-1].room_no!=unallot)
				{
					System.out.println("Room Is Vacant!");
					break;
				}
				r[unallot-1].display();
				Calendar date1=Calendar.getInstance();
				System.out.println("Enter the Date Today in Numerical Form:");
				System.out.println("Day:");
				int d6=scan.nextInt();
				System.out.println("Month:");
				int d5=scan.nextInt();
				System.out.println("Year:");
				int d4=scan.nextInt();
				date1.set(d4,d5,d6);
				long diff=date1.getTimeInMillis()-r[unallot-1].in.getTimeInMillis();
				long x=diff/(24*60*60*1000);
				r[unallot-1].billing(x);
				System.out.println("Thanks For Your Visit");
				r[unallot-1]=new Room();
				Room.vacant++;
				break;
		
			
		case 5: x1=0;
				break;
		default:try
				{
					throw ex;
				}
				catch(WrongInputException e)
				{
					System.out.println(e);
				}
	  }
	}
  }
}

Github source code: link

Why This Is a Great Java Project for Students

  • It includes real-world scenarios like room booking, food orders, and billing.
  • It teaches proper class-based design and code structure.
  • It uses a menu-based system, which is common in many CLI applications.
  • You learn to handle dates, arrays, static variables, and exceptions.
  • The project can be extended — you can add login, room types, discount offers, payment modes, etc.

Final Thoughts

This Hotel Management System is a perfect mini-project to practice your Java skills. It covers almost every important topic a beginner should know: class design, exception handling, input/output, static variables, and basic logic building. For more such amazing java projects visit here.

Post navigation

❮ Previous Post: Here’s the Real Reason Behind Massive Layoffs at Big Companies
Next Post: Download YouTube Videos Using Python – Step-by-Step Guide ❯

Leave a Reply Cancel reply

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

  • About Us
  • Contact Us
  • Privacy Policy
  • Disclaimer

Copyright © 2025 codehelping.com.

Theme: Oceanly by ScriptsTown

Social Chat is free, download and try it now here!