Answer to Question #271818 in Java | JSP | JSF for ABEYRATHNA

Question #271818

Develop a system by using Java programming language and object-oriented programming concepts for a hotel room reservation system. It should be a menu-driven stand-alone console application (No GUI required). No need to connect any database as well, but you may use file operations if required (not mandatory). Your system must have the following functionalities

o Register guests

o View available rooms

o Allocate a room for a guest

o Change/ delete room allocation for a guest

o Check-in to a room

o Checkout from a room

o Generate the bill


1
Expert's answer
2021-11-26T17:44:20-0500
import java.util.Scanner;
public class Main
{
    static void RegisterGuest(){
        Scanner input=new Scanner(System.in);
        System.out.println("Enter the name of the guest: ");
        String N=input.next();
        System.out.println("Enter the ID number of the guest: ");
        int num=input.nextInt();
        System.out.println("Enter the gender: ");
        String G=input.next();
        System.out.println("Enter the age of the guest: ");
        int Age=input.nextInt();
    }
    static void AvailableRooms(){
        
        System.out.println("Available rooms are: ");
        System.out.println("1.Room 1 - Ladies  1000\n2. Room 2 - gents 1000\n3. Room 3 -  couples  1500\n4. Room 4 -1800");
    }
    static void AllocateRoom(){
        Scanner input=new Scanner(System.in);
        System.out.println("Enter room number: ");
        int R=input.nextInt();
        System.out.println("Enter the name of the guest: ");
        String N=input.next();
        System.out.println("Enter the gender: ");
        String G=input.next();
        System.out.println("Enter the ID number of the guest: ");
        int num=input.nextInt();
        System.out.println("Room number "+R+" is allocated to "+N+" "+G+" "+"of ID number "+num);
    }
    static void DeleteRoom(){
        Scanner input=new Scanner(System.in);
        System.out.println("Enter the room number ");
        int num=input.nextInt();
        System.out.println("Enter the guest name: ");
        String N=input.next();
        System.out.println("Room number  "+num+" "+"deallocated"+" from guest name "+N);
    }
    static void CheckInRoom(){
        Scanner input=new Scanner(System.in);
        System.out.println("Enter the room number ");
        int R=input.nextInt();
        System.out.println("Enter your name ");
        String N=input.next();
        System.out.println(N+" you entered room number "+ R);
    }
    static void CheckOutRoom(){
        Scanner input=new Scanner(System.in);
        System.out.println("Enter the room number ");
        int R=input.nextInt();
        System.out.println("Room number  "+R+" "+"empty");
    }
    static void GenerateBill(){
        Scanner input=new Scanner(System.in);
        System.out.println("Enter the room number ");
        int R=input.nextInt();
        System.out.print("Enter the number of days you have stayed in the room ");
        int D=input.nextInt();
        if(R==1){
            int total=1000*D;
            System.out.print("Total bill is "+total);
        }
        else if(R==2){
            int total=1000*D;
            System.out.print("Total bill is "+total);
        }
        else if(R==3){
            int total=1500*D;
            System.out.print("Total bill is "+total);
        }
        else if(R==4){
            int total=1800*D;
            System.out.print("Total bill is "+total);
        }
        else{
            int total=1500*D;
            System.out.print("Total bill is "+total);
        }}
	public static void main(String[] args) {
		Scanner input=new Scanner(System.in);
		System.out.print("\n1.Register guests\n2.View available rooms\n3. Allocate a room for a guest\n4. Change/ delete room allocation for a guest\n5. Check-in to a room\n6. Checkout from a room\n7. Generate the bill");
	   System.out.print("\nChoose an option: ");
		int option=input.nextInt();
	   if(option==1){
	       RegisterGuest();
	   }
	    else if(option==2){
	       AvailableRooms();
	   }
	   else if(option==3){
	       AllocateRoom();
	   }
	   else if(option==4){
	       DeleteRoom();
	   }
	   else if(option==5){
	      CheckInRoom();
	   }
	   else if(option==6){
	      CheckOutRoom();
	   }
	   else if(option==7){
	      GenerateBill();
	   }
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

KN ABEYRATHNA
27.11.21, 10:49

Thank you very much for your support.

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS