:) Greetings and, does anybody have any ideas?--For I am working on a Java Proje
ID: 3555764 • Letter: #
Question
:) Greetings and, does anybody have any ideas?--For I am working on a Java Project and below is the code that I have so far: And I am stuck on the part of developing a method (the method is called bookRoom and should be located in the Reservation class below) that:
1.The main application provides the user with four options for: making a reservation, checking-out, viewing the rooms status and an exit option.
2.When the user selects to make a reservation, a list of available rooms with the room number and smoking/non-smoking information will be displayed and the user will be asked to select a room. Once the user selects an available room, the system asks for a phone number, number of the guests (maximum four guests) and the name of the guests.
3.When the user selects to check-out, the system asks user for the room number and puts that room back to the list of available rooms.
4.When the user selects to view the rooms status, the system displays the information for all rooms: The room number, the smoking/non-smoking information, and the phone number and the name of all guests for the occupied rooms.
5. When the user selects to terminate, the program terminates. Otherwise, the program is always waiting for the user
Explanation / Answer
Method Code:
void makeReservation()
{
System.out.println("Room Reservation:");
System.out.println("1.Smoking Room");
System.out.println("2.Non Smooking Room");
int type=sc.nextInt();
if(type==1)
if(sAvailable>0)
{
System.out.println("Please enter number of guests:");
int checkinGuests=sc.nextInt();
totalGuests+=checkinGuests;
if(checkinGuests%4==0)
sAvailable-=checkinGuests/4;
else
sAvailable-=(checkinGuests/4)+1;
System.out.println("The number of rooms alloted to you is:"+(5-sAvailable));
System.out.println("Please select the room numbers:");
for(int i=0;i<(5-sAvailable);i++)
{
int roomNum=sc.nextInt();
if(sRooms[roomNum]!=1)
sRooms[roomNum]=1;
else
{
System.out.println("Not available!Select other");
i--;
}
}
System.out.println("Please enter your phone number");
phone=sc.nextInt();
System.out.println("Enter the names of guests:");
for(int i=0;i<=checkinGuests;i++)
{
names[i]=sc.nextLine();
}
}
else
{
System.out.println("Sorry! No rooms available. Select another category");
makeReservation();
}
else
if(nsAvailable>0)
{
System.out.println("Please enter number of guests:");
int checkinGuests=sc.nextInt();
totalGuests+=checkinGuests;
if(checkinGuests%4==0)
nsAvailable-=checkinGuests/4;
else
nsAvailable-=(checkinGuests/4)+1;
System.out.println("The number of rooms alloted to you is:"+(25-nsAvailable));
System.out.println("Please select the room numbers:");
for(int i=0;i<(25-nsAvailable);i++)
{
int roomNum=sc.nextInt();
if(nsRooms[roomNum]!=1)
nsRooms[roomNum]=1;
else
{
System.out.println("Not available!Select other");
i--;
}
}
System.out.println("Please enter your phone number");
phone=sc.nextInt();
System.out.println("Enter the names of guests:");
for(int i=0;i<=checkinGuests;i++)
{
names[i]=sc.nextLine();
}
}
else
{
System.out.println("Sorry! No rooms available. Select another category");
makeReservation();
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.