Can anyone help me with this Java project? Sorry I post it again because I forgo
ID: 3567203 • Letter: C
Question
Can anyone help me with this Java project? Sorry I post it again because I forgot to add the rules. Thank you in advance!design a hotel reservation system. The hotel will have nine rooms, rooms 1-3 are $100/night, 4-6 are $200/night, and 7-9 are $300/night. The application will provide a list to choose from with the following options:
check room availability
book a room (which will save clients name and number of days
cancel a room
provide room rate
print information for room: client info, number of days booked, rate, room number (if not book, should return a message saying it's available and the rate)
quit (the application)
The application should ensure a valid choice is entered, then process the choice. Once done, assuming the choice wasn't to quit, the menu is displayed and ready for another choice.
1. Try to not make one huge method to do it all...break things down as much as possible. 2. Documentation is important 3. Every class needs its own file. 4. You are not required to make it a simulation.i.e. you don't decrement days and such. Can anyone help me with this Java project? Sorry I post it again because I forgot to add the rules. Thank you in advance!
design a hotel reservation system. The hotel will have nine rooms, rooms 1-3 are $100/night, 4-6 are $200/night, and 7-9 are $300/night. The application will provide a list to choose from with the following options:
check room availability
book a room (which will save clients name and number of days
cancel a room
provide room rate
print information for room: client info, number of days booked, rate, room number (if not book, should return a message saying it's available and the rate)
quit (the application)
The application should ensure a valid choice is entered, then process the choice. Once done, assuming the choice wasn't to quit, the menu is displayed and ready for another choice.
1. Try to not make one huge method to do it all...break things down as much as possible. 2. Documentation is important 3. Every class needs its own file. 4. You are not required to make it a simulation.i.e. you don't decrement days and such.
design a hotel reservation system. The hotel will have nine rooms, rooms 1-3 are $100/night, 4-6 are $200/night, and 7-9 are $300/night. The application will provide a list to choose from with the following options:
check room availability
book a room (which will save clients name and number of days
cancel a room
provide room rate
print information for room: client info, number of days booked, rate, room number (if not book, should return a message saying it's available and the rate)
quit (the application)
The application should ensure a valid choice is entered, then process the choice. Once done, assuming the choice wasn't to quit, the menu is displayed and ready for another choice. design a hotel reservation system. The hotel will have nine rooms, rooms 1-3 are $100/night, 4-6 are $200/night, and 7-9 are $300/night. The application will provide a list to choose from with the following options:
check room availability
book a room (which will save clients name and number of days
cancel a room
design a hotel reservation system. The hotel will have nine rooms, rooms 1-3 are $100/night, 4-6 are $200/night, and 7-9 are $300/night. The application will provide a list to choose from with the following options:
check room availability
design a hotel reservation system. The hotel will have nine rooms, rooms 1-3 are $100/night, 4-6 are $200/night, and 7-9 are $300/night. The application will provide a list to choose from with the following options:
provide room rate
print information for room: client info, number of days booked, rate, room number (if not book, should return a message saying it's available and the rate)
quit (the application)
The application should ensure a valid choice is entered, then process the choice. Once done, assuming the choice wasn't to quit, the menu is displayed and ready for another choice.
1. Try to not make one huge method to do it all...break things down as much as possible. 2. Documentation is important 3. Every class needs its own file. 4. You are not required to make it a simulation.i.e. you don't decrement days and such.
Explanation / Answer
//Customer class to store name and number of days room booked
//Customer.java
public class Customer
{
private String name;
private int daysBooked;
public Customer() {
// TODO Auto-generated constructor stub
}
Customer(String name,int daysBooked)
{
this.name=name;
this.daysBooked=daysBooked;
}
public void setName(String name)
{
this.name=name;
}
public String getName()
{
return name;
}
public void setDays(int daysBooked)
{
this.daysBooked=daysBooked;
}
public int getDays()
{
return daysBooked;
}
@Override
public String toString() {
// TODO Auto-generated method stub
return "Name :"+name+"Days Booked : "+daysBooked;
}
}
--------------------------------------------------------------------------------------------------------
//The class contains the methods to check availabily of rooms
//,booking a room, cancel a room ,display room rates and
//and print user information
//Room.java
import java.util.Scanner;
public class Room
{
private int NUM_ROOMS;
private int roomNumber;
private int rate;
private int daysBooked;
private boolean[] roomsAvailable=new boolean[9];
private static Customer client=new Customer();
public Room()
{
// TODO Auto-generated constructor stub
NUM_ROOMS=9;
}
public void bookRoom()
{
Scanner read=new Scanner(System.in);
if(isAvailable())
{
System.out.println("Enter Name :");
String name= read.next();
System.out.println("Number of Days :");
int daysBooked=read.nextInt();
client.setName(name);
System.out.println("Enter room number :");
client.setDays(daysBooked);
setRate(roomNumber);
}
}
private void setRate(int roomNumber)
{
if(roomNumber>=1 && roomNumber<=3)
rate=100;
else if(roomNumber>=4 && roomNumber<=6)
rate=200;
else if(roomNumber>=7 && roomNumber<=9)
rate=300;
}
public void cancelRoom()
{
if(NUM_ROOMS>0)
{
NUM_ROOMS=NUM_ROOMS-1;
System.out.println("Room has canceled.");
}
else
System.out.println("No Rooms booked.");
}
public boolean isAvailable()
{
Scanner read=new Scanner(System.in);
boolean avail=false;
if(NUM_ROOMS>0)
{
System.out.println("Enter room number :");
roomNumber=read.nextInt();
if(roomsAvailable[roomNumber]==false)
{
System.out.println("Room available");
avail=true;
}
else
System.out.println("Room is booked. Select another room.");
}
return avail;
}
public void printRooms()
{
System.out.println("Rooms : 1-3 @100$/Night");
System.out.println("Rooms : 4-6 @200$/Night");
System.out.println("Rooms : 7-9 @300$/Night");
}
public void printRoomInformation()
{
System.out.println("Customer Name :"+client.getName());
System.out.println("Number of days :"+client.getDays());
System.out.println("Number of days booked :"+daysBooked);
System.out.println("Room Rate : "+rate);
}
}
______________________________________________________
//The class test the class Room and customer
//and prompts the user to enter the option
//and execute the corresponding method .
//TesterClass.java
//Compile: javac TesterClass.java
//Run: java TesterClass
import java.util.Scanner;
public class TesterClass
{
public static void main(String[] args)
{
/*check room availability
book a room (which will save clients name and number of days
cancel a room
provide room rate
print information for room: client info, number of days booked, rate, room number (if not book, should return a message
saying it's available and the rate)
quit (the application) */
menu();
}
//menu of choices for customers
public static int menu()
{
Scanner read=new Scanner(System.in);
int choice=0;
do
{
System.out.println("1.Check availability ");
System.out.println("2.Book Room");
System.out.println("3.Cancel room");
System.out.println("4.Display room rates");
System.out.println("5.Print room information");
System.out.println("6.Exit ");
System.out.println("Enter your choice :");
choice=read.nextInt();
if(choice<0 || choice>5)
System.out.println("Invalid choice");
Room roomObject=new Room();
switch (choice) {
case 1:
roomObject.isAvailable();
break;
case 2:
roomObject.bookRoom();
break;
case 3:
roomObject.cancelRoom();
break;
case 4:
roomObject.printRooms();
break;
case 5:
roomObject.printRoomInformation();
break;
case 6:
System.exit(0);
}
} while (true);
}
}
------------------------------------------------------------------------------------
Sample O/p:
1.Check availability
2.Book Room
3.Cancel room
4.Display room rates
5.Print room information
6.Exit
Enter your choice :
2
Enter room number :
1
Room available
Enter Name :
joh
Number of Days :
10
Enter room number :
1.Check availability
2.Book Room
3.Cancel room
4.Display room rates
5.Print room information
6.Exit
Enter your choice :
5
Customer Name :joh
Number of days :10
Number of days booked :0
Room Rate : 0
1.Check availability
2.Book Room
3.Cancel room
4.Display room rates
5.Print room information
6.Exit
Enter your choice :
Hope this would help
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.