integers taken as input.
14.) A hotel has following special rates for stay depending upon number of days :
Rate
Number of days
First 3 days
Rs. 350/- per day
For next 3 days
Rs. 300/- per day
For next 3 days
Rs. 275/- per day
Any day beyond 9 days
Rs. 225/- per day
Write a program to input number of days stayed, room number allotted, check-in time and check-out time.
Calculate the bill amount. Print number of days stayed, room number, check-in time, check-out time and total
amount to be paid by the person in the following format :
XYZ INTERNATIONAL HOTEL
NUMBER OF DAYS STAYED :
CHECK-IN TIME :
CHECK-OUT TIME :
AMOUNT TO BE PAID :
Answers
Explanation:
import java.util.Scanner; public class KboatHotel { public static void main(String args[]) { Scanner in = new Scanner(System.in); System.out.print("Enter number of days stayed: "); int noDays = in.nextInt(); System.out.print("Enter room number alloted: "); int roomNo = in.nextInt(); in.nextLine(); System.out.print("Enter check-in time: "); String inTime = in.nextLine(); System.out.print("Enter check-out time: "); String outTime = in.nextLine(); int amt = 0; if (noDays <= 3) amt = noDays * 350; else if (noDays <= 6) amt = 3 * 350 + ((noDays - 3) * 300); else if (noDays <= 9) amt = 3 * 350 + 3 * 300 + ((noDays - 6) * 275); else amt = 3 * 350 + 3 * 300 + 3 * 275 + ((noDays - 9) * 225); System.out.println("\t\tXYZ INTERNATIONAL HOTEL"); System.out.println("ROOM NUMBER: " + roomNo); System.out.println("NUMBER OF DAYS STAYED: " + noDays); System.out.println("CHECK-IN TIME: " + inTime); System.out.println("CHECK-OUT TIME: " + outTime); System.out.println("AMOUNT TO BE PAID: " + amt); } }