0% found this document useful (0 votes)
8 views13 pages

Import Java

The document is a Java program for a Hotel Management System that allows users to manage room bookings, cancellations, and check-outs. It provides options to view available rooms, book a room with meal plans, cancel bookings, check out, and view loyalty points. The program utilizes a command-line interface for user interaction and manages up to five rooms with associated guest information.

Uploaded by

suhan.patel
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views13 pages

Import Java

The document is a Java program for a Hotel Management System that allows users to manage room bookings, cancellations, and check-outs. It provides options to view available rooms, book a room with meal plans, cancel bookings, check out, and view loyalty points. The program utilizes a command-line interface for user interaction and manages up to five rooms with associated guest information.

Uploaded by

suhan.patel
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

import [Link].

Scanner;

public class HotelManagement {

public static void main(String[] args) {

// Room info stored in separate variables as required

String room1 = null, room2 = null, room3 = null, room4 = null, room5 = null;

String room1Type = null, room2Type = null, room3Type = null, room4Type = null,


room5Type = null;

String room1Meal = null, room2Meal = null, room3Meal = null, room4Meal = null,


room5Meal = null;

String room1GuestInfo = null, room2GuestInfo = null, room3GuestInfo = null,


room4GuestInfo = null, room5GuestInfo = null;

int room1Nights = 0, room2Nights = 0, room3Nights = 0, room4Nights = 0, room5Nights = 0;

int loyaltyPoints = 0;

Scanner scanner = new Scanner([Link]);

while (true) {

[Link]("\nHotel Management System");

[Link]("1. Show Available Rooms");

[Link]("2. Book a Room");

[Link]("3. Cancel Booking");

[Link]("4. Show Booked Rooms");

[Link]("5. Check Out");

[Link]("6. View Loyalty Points");


[Link]("7. Exit");

[Link]("Enter your choice: ");

int choice = [Link]();

[Link]();

if (choice == 1) {

[Link]("Available Rooms:");

boolean anyAvailable = false;

for (int i = 1; i <=5; i++) {

String occupant = null;

switch (i) {

case 1: occupant = room1; break;

case 2: occupant = room2; break;

case 3: occupant = room3; break;

case 4: occupant = room4; break;

case 5: occupant = room5; break;

if (occupant == null) {

[Link]("Room " + i);

anyAvailable = true;

if (!anyAvailable) {

[Link]("No rooms available.");

}
} else if (choice == 2) {

[Link]("Enter your full name: ");

String fullName = [Link]();

[Link]("Enter your phone number: ");

String phone = [Link]();

[Link]("Enter your email address: ");

String email = [Link]();

[Link]("Choose room type (1-Single(₹5000), 2-Double(₹9000), 3-


Suite(₹15000)): ");

int roomTypeChoice = [Link]();

[Link]();

String selectedRoomType;

switch (roomTypeChoice) {

case 1: selectedRoomType = "Single"; break;

case 2: selectedRoomType = "Double"; break;

case 3: selectedRoomType = "Suite"; break;

default:

[Link]("Invalid room type, defaulting to Single.");

selectedRoomType = "Single";

[Link]("Meal Plans:");
[Link]("1. None");

[Link]("2. Breakfast - ₹1000");

[Link]("3. Half Board (Breakfast + Dinner) - ₹2000");

[Link]("4. Full Board (All meals) - ₹3000");

[Link]("Choose meal plan (1-4): ");

int mealChoice = [Link]();

[Link]();

String selectedMealPlan;

switch (mealChoice) {

case 1: selectedMealPlan = "None"; break;

case 2: selectedMealPlan = "Breakfast"; break;

case 3: selectedMealPlan = "Half Board"; break;

case 4: selectedMealPlan = "Full Board"; break;

default:

[Link]("Invalid meal choice, defaulting to None.");

selectedMealPlan = "None";

[Link]("Enter number of nights you will stay: ");

int nightsStay = [Link]();

[Link]();

String guestInfo = "Name: " + fullName + ", Phone: " + phone + ", Email: " + email;

boolean booked = false;


for (int i = 1; i <= 5; i++) {

String occupant = null;

switch (i) {

case 1: occupant = room1; break;

case 2: occupant = room2; break;

case 3: occupant = room3; break;

case 4: occupant = room4; break;

case 5: occupant = room5; break;

if (occupant == null) {

switch (i) {

case 1:

room1 = fullName; room1Type = selectedRoomType; room1Meal =


selectedMealPlan; room1GuestInfo = guestInfo; room1Nights = nightsStay;

break;

case 2:

room2 = fullName; room2Type = selectedRoomType; room2Meal =


selectedMealPlan; room2GuestInfo = guestInfo; room2Nights = nightsStay;

break;

case 3:

room3 = fullName; room3Type = selectedRoomType; room3Meal =


selectedMealPlan; room3GuestInfo = guestInfo; room3Nights = nightsStay;

break;

case 4:

room4 = fullName; room4Type = selectedRoomType; room4Meal =


selectedMealPlan; room4GuestInfo = guestInfo; room4Nights = nightsStay;

break;
case 5:

room5 = fullName; room5Type = selectedRoomType; room5Meal =


selectedMealPlan; room5GuestInfo = guestInfo; room5Nights = nightsStay;

break;

[Link]("Room " + i + " has been booked for " + fullName + ".");

booked = true;

break;

if (!booked) {

[Link]("Sorry, no rooms available for booking.");

} else if (choice == 3) {

[Link]("Enter room number to cancel booking: ");

int roomNumber = [Link]();

[Link]();

boolean validCancel = false;

switch (roomNumber) {

case 1:

if (room1 != null) {

[Link]("Booking for room 1 cancelled (customer: " + room1 + ").");

room1 = room1Type = room1Meal = room1GuestInfo = null;

room1Nights = 0;

validCancel = true;
}

break;

case 2:

if (room2 != null) {

[Link]("Booking for room 2 cancelled (customer: " + room2 + ").");

room2 = room2Type = room2Meal = room2GuestInfo = null;

room2Nights = 0;

validCancel = true;

break;

case 3:

if (room3 != null) {

[Link]("Booking for room 3 cancelled (customer: " + room3 + ").");

room3 = room3Type = room3Meal = room3GuestInfo = null;

room3Nights = 0;

validCancel = true;

break;

case 4:

if (room4 != null) {

[Link]("Booking for room 4 cancelled (customer: " + room4 + ").");

room4 = room4Type = room4Meal = room4GuestInfo = null;

room4Nights = 0;

validCancel = true;

break;
case 5:

if (room5 != null) {

[Link]("Booking for room 5 cancelled (customer: " + room5 + ").");

room5 = room5Type = room5Meal = room5GuestInfo = null;

room5Nights = 0;

validCancel = true;

break;

if (!validCancel) {

[Link]("Invalid room number or room is not booked.");

} else if (choice == 4) {

boolean anyBooked = false;

[Link]("Booked Rooms:");

for (int i = 1; i <= 5; i++) {

String occupant = null, type = null, meal = null, guestInfo = null;

int nightsStayed = 0;

switch (i) {

case 1: occupant = room1; type = room1Type; meal = room1Meal; guestInfo =


room1GuestInfo; nightsStayed = room1Nights; break;

case 2: occupant = room2; type = room2Type; meal = room2Meal; guestInfo =


room2GuestInfo; nightsStayed = room2Nights; break;

case 3: occupant = room3; type = room3Type; meal = room3Meal; guestInfo =


room3GuestInfo; nightsStayed = room3Nights; break;
case 4: occupant = room4; type = room4Type; meal = room4Meal; guestInfo =
room4GuestInfo; nightsStayed = room4Nights; break;

case 5: occupant = room5; type = room5Type; meal = room5Meal; guestInfo =


room5GuestInfo; nightsStayed = room5Nights; break;

if (occupant != null) {

[Link]("Room " + i + " - " + occupant);

[Link](" Type: " + type);

[Link](" Meal Plan: " + meal);

[Link](" Guest Info: " + guestInfo);

[Link](" Nights Stayed: " + nightsStayed);

anyBooked = true;

if (!anyBooked) {

[Link]("No rooms are currently booked.");

} else if (choice == 5) {

[Link]("Enter room number to check out: ");

int roomNumber = [Link]();

[Link]();

String guestName = null, type = null, meal = null, guestInfo = null;

int stayNights = 0;

boolean validCheckout = false;

switch (roomNumber) {
case 1:

guestName = room1; type = room1Type; meal = room1Meal; guestInfo =


room1GuestInfo; stayNights = room1Nights;

break;

case 2:

guestName = room2; type = room2Type; meal = room2Meal; guestInfo =


room2GuestInfo; stayNights = room2Nights;

break;

case 3:

guestName = room3; type = room3Type; meal = room3Meal; guestInfo =


room3GuestInfo; stayNights = room3Nights;

break;

case 4:

guestName = room4; type = room4Type; meal = room4Meal; guestInfo =


room4GuestInfo; stayNights = room4Nights;

break;

case 5:

guestName = room5; type = room5Type; meal = room5Meal; guestInfo =


room5GuestInfo; stayNights = room5Nights;

break;

if (guestName != null) {

// Calculate bill inline

int roomCost = 0, mealCost = 0;

if ("Single".equals(type)) {

roomCost = 5000;
} else if ("Double".equals(type)) {

roomCost = 9000;

} else if ("Suite".equals(type)) {

roomCost = 15000;

if ("None".equals(meal)) {

mealCost = 0;

} else if ("Breakfast".equals(meal)) {

mealCost = 1000;

} else if ("Half Board".equals(meal)) {

mealCost = 2000;

} else if ("Full Board".equals(meal)) {

mealCost = 3000;

int cost = (roomCost + mealCost) * stayNights;

[Link]("Billing for Room " + roomNumber + " - " + guestName + ":");

[Link]("Total amount due: ₹" + cost);

int pointsEarned = cost / 1000;

loyaltyPoints += pointsEarned;

[Link]("You earned " + pointsEarned + " loyalty points this stay.");

[Link]("Total loyalty points accumulated: " + loyaltyPoints);

[Link]("Thank you for staying with us!");


// Clear room data

switch (roomNumber) {

case 1:

room1 = room1Type = room1Meal = room1GuestInfo = null;

room1Nights = 0;

break;

case 2:

room2 = room2Type = room2Meal = room2GuestInfo = null;

room2Nights = 0;

break;

case 3:

room3 = room3Type = room3Meal = room3GuestInfo = null;

room3Nights = 0;

break;

case 4:

room4 = room4Type = room4Meal = room4GuestInfo = null;

room4Nights = 0;

break;

case 5:

room5 = room5Type = room5Meal = room5GuestInfo = null;

room5Nights = 0;

break;

validCheckout = true;

}
if (!validCheckout) {

[Link]("Invalid room number or room is not booked.");

} else if (choice == 6) {

[Link]("Total loyalty points accumulated: " + loyaltyPoints);

} else if (choice == 7) {

[Link]("Thank you for using the Hotel Management System!");

break;

} else {

[Link]("Invalid choice! Please enter a number between 1 and 7.");

[Link]();

You might also like