A hotel has following special rates for staying depending upon number of days:
[5]
Number of days
Rates
First 3 days
5000/- per day
For next 3 days
3000/- per day
For any day beyond 6 days
2000/- per day
Write a program to input name, number of days stayed, check-in date and
check-out date. Calculate bill amount and print the following
Name of Customer: XXX
No. of days stayed: XX
Check-In date: XXX
Check-Out date: XXX
Total amount to be paid: XXX
Answers
Answer:
can you tell which kind of program
Answer:
import java.util.*;
public class Hotel
{
String name;int no_ofdays,in_time,out_time;double total_amt,rate;int room_num;
public void method()
{
Scanner sc1=new Scanner(System.in);
System.out.println("ENTER YOUR NAME");
name=sc1.next();
Scanner sc2=new Scanner(System.in);
System.out.println("ENTER NUMBER OF DAYS STAYED");
no_ofdays=sc2.nextInt();
Scanner sc3=new Scanner(System.in);
System.out.println("ENTER CHECK-IN TIME");
in_time=sc3.nextInt();
Scanner sc4=new Scanner(System.in);
System.out.println("ENTER CHECK-OUT TIME");
out_time=sc3.nextInt();
Scanner sc5=new Scanner(System.in);
if(no_ofdays<=3)
{
rate=350;
}
else if(no_ofdays>3 && no_ofdays<=6)
{
rate=300;
}
else if(no_ofdays>6 && no_ofdays<=9)
{
rate=275;
}
else if(no_ofdays>9)
{
rate=225;
}
{
System.out.println(" ROHAN INTERNATIONAL HOTEL ");
System.out.println("NAME:"+name);
System.out.println("NUMBER OF DAYS STAYED:"+no_ofdays);
System.out.println("CHECK-IN TIME:"+in_time);
System.out.println("CHECK-OUT TIME:"+out_time);
System.out.println("TOTAL AMOUNT TO BE PAID:"+(rate*no_ofdays));
System.out.println("THANK YOU!!");
System.out.println("HOPE YOU HAD A GOOD TIME IN THIS HOTEL");
System.out.println("PLEASE VISIT AGAIN");
}
}
}
Explanation:
For these king of programs we can use both constructor as well as scanner class but i could provide only with scanner class
Sorry