
Create a program, which calculates room charges for a certain hotel in java
calculates room charges – You are tasked with creating a system that determines the cost of a hotel room. Delux-Double, Standard-Family, and Standard-Single Rooms are all on offer. The price of your room will vary based on the amenities you demand.
Sure, here’s an example Java program that calculates room charges for a hotel:
calculates room charges in JAVA
import java.util.Scanner;
public class HotelRoomCharges {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print(“Enter the number of nights you will stay: “);
int numNights = sc.nextInt();
System.out.print(“Enter the number of guests: “);
int numGuests = sc.nextInt();
System.out.print(“Enter the room type (1 for standard, 2 for deluxe, 3 for suite): “);
int roomType = sc.nextInt();
double baseCharge;
if (roomType == 1) {
baseCharge = 100.0;
} else if (roomType == 2) {
baseCharge = 150.0;
} else if (roomType == 3) {
baseCharge = 250.0;
} else {
System.out.println(“Invalid room type entered.”);
return;
}
double numRooms = Math.ceil(numGuests / 2.0);
double roomCharge = numRooms * baseCharge;
double taxRate = 0.1;
double tax = roomCharge * taxRate;
double totalCharge = roomCharge + tax + (numNights * 10.0);
System.out.println(“Room charge: $” + roomCharge);
System.out.println(“Tax: $” + tax);
System.out.println(“Additional charges (for ” + numNights + ” nights): $” + (numNights * 10.0));
System.out.println(“Total charge: $” + totalCharge);
}
}
This program prompts the user for the number of nights they will stay, the number of guests, and the type of room they want. It then calculates the room charge based on the number of guests and the room type, adds in taxes and any additional charges, and outputs the total charge. The program assumes that two guests can stay in a room, so it calculates the number of rooms needed based on the number of guests entered. The tax rate is set at 10%, and there is an additional charge of $10 per night for each room.
Download Any Jobs Application Form For 500 + |
Download Jobs Application Form For Every Jobs |
Resume Templates Top 20 in MS Word – CV Format |
Disclaimer Confirm everything before applying for a job or giving an advance to a similar officer. We are not responsible for any damage or loss.