0% found this document useful (0 votes)
11 views2 pages

New Text Document

Uploaded by

Lohith Seedella
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views2 pages

New Text Document

Uploaded by

Lohith Seedella
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

import java.io.

*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

class Hotel{
int roomno;
String roomType;
int capacity;
double ppn;
boolean isava;

public Hotel(int no, String type,int cap,double ppn,boolean isava){


this.roomno = no;
this.roomType = type;
this.capacity = cap;
this.ppn = ppn;
this.isava = isava;
}

public String toString(){


return roomno+"\n"+roomType+"\n"+capacity+"\n"+ppn+"\n"+isava;
}
}

public class Solution {

public static Hotel roomBookingByUsingRoomNo(List<Hotel> l,int rid){


for(Hotel val : l){
if(val.roomno == rid && val.isava == true){
val.isava = false;
return val;
}
}
return null;
}

public static Hotel findMaxCapacityRoomBasedonAvalibility(List<Hotel> l){


int maxcap = 0;
int id =0;
for(Hotel val : l){
if(maxcap < val.capacity && val.isava == true ){
maxcap = val.capacity;
}
}
for(Hotel val :l){
if(val.capacity == maxcap ){
return val;
}
}
return null;
}

public static void main(String args[]) throws Exception {


/* Enter your code here. Read input from STDIN. Print output to STDOUT */
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
List<Hotel> l = new ArrayList<>();
for(int i=0;i<n;i++){
int rno = sc.nextInt();
sc.nextLine();
String rType = sc.nextLine();
int cap = sc.nextInt();
double ppn = sc.nextDouble();
boolean isava = sc.nextBoolean();

l.add(new Hotel(rno, rType, cap, ppn, isava));


}
int find = sc.nextInt();

Hotel obj1 =roomBookingByUsingRoomNo(l,find);


if(obj1!=null){
System.out.println("Room No: "+obj1.roomno);
System.out.println("Room Type: "+obj1.roomType);
System.out.println("Capacity: "+obj1.capacity);
System.out.println("Price: "+obj1.ppn);

}else{
System.out.println("No room found with given attributes");
}

Hotel obj2 = findMaxCapacityRoomBasedonAvalibility(l);


if(obj2!=null){
System.out.println("Room No: "+obj2.roomno);
System.out.println("Room Type: "+obj2.roomType);
System.out.println("Capacity: "+obj2.capacity);
System.out.println("Price: "+obj2.ppn);
}else{
System.out.println("Rooms are not available");
}

}
}

You might also like