Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello. I need help with writing a code in java. I want to make a simple hotel re

ID: 3839191 • Letter: H

Question

Hello. I need help with writing a code in java.
I want to make a simple hotel reservation program. I've created three classes: Room,Reservation,Guest
In the Room class, i have: String roomType; Int roomNum; Double pricePerNight; As instance variables. And i want to create a static array of Room within the class, that takes these variables, of size [10][20]
My question is how can I do that. Given that there is 10 floors in the hotel and each floor takes 20 rooms. 101-120,201-220,301-320......
Type is single from 101-520, 601-820 double, 901-1020 suite.
And price is 200 for single, 400 for double, 1000 for suite.

Hello. I need help with writing a code in java.
I want to make a simple hotel reservation program. I've created three classes: Room,Reservation,Guest
In the Room class, i have: String roomType; Int roomNum; Double pricePerNight; As instance variables. And i want to create a static array of Room within the class, that takes these variables, of size [10][20]
My question is how can I do that. Given that there is 10 floors in the hotel and each floor takes 20 rooms. 101-120,201-220,301-320......
Type is single from 101-520, 601-820 double, 901-1020 suite.
And price is 200 for single, 400 for double, 1000 for suite.

Hello. I need help with writing a code in java.
I want to make a simple hotel reservation program. I've created three classes: Room,Reservation,Guest
In the Room class, i have: String roomType; Int roomNum; Double pricePerNight; As instance variables. And i want to create a static array of Room within the class, that takes these variables, of size [10][20]
My question is how can I do that. Given that there is 10 floors in the hotel and each floor takes 20 rooms. 101-120,201-220,301-320......
Type is single from 101-520, 601-820 double, 901-1020 suite.
And price is 200 for single, 400 for double, 1000 for suite.

Explanation / Answer


public class JavaHotel
{
public static void main(String[] args)
{
System.out.println("Welcome to our hotel.");
Scanner aScanner = new Scanner(System.in);
System.out.println("To begin, please mention how many rooms you want . ");
int numberOfGuests = aScanner.nextInt();
System.out.println("Thank you. Now can you tell me how many days. ");
int numberOfNights = aScanner.nextInt();
if (numberOfNights <=7 && numberOfGuests == 5)
{
System.out.println("For " + numberOfGuests + " guest staying for "
+ numberOfNights + " nights, it will cost "
+ "€" + 95 * numberOfNights);
}
else if (numberOfNights <=7 && numberOfGuests >5)
{
System.out.println("For " + numberOfGuests + " guests staying for "
+ numberOfNights + " nights, it will cost " + "€" + numberOfNights * 80);
}
else if (numberOfNights >7&& numberOfGuests == 5)
{
System.out.println("For " + numberOfGuests + " guest staying for "
+ numberOfNights + " nights, it will cost " + "€"
+ (2*95*numberOfGuests + (numberOfNights - 2)*65*numberOfGuests));
}
else if (numberOfNights >7 && numberOfGuests > 5)
{
System.out.println("For " + numberOfGuests + " guests staying for "
+ numberOfNights + " nights, it will cost " + "€"
+ (7*80*numberOfGuests + (numberOfNights - 7)*50*numberOfGuests));
}
}