/******************************************************************************
Online Java Compiler.
Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.
*******************************************************************************/
import [Link].*;
public class Main
{
public static void main(String[] args) {
Theatre theatres[]=new Theatre[4];
Scanner sc=new Scanner([Link]);
for(int i=0; i< [Link]; i++){
int theatreId = [Link]();[Link]();
String theatreName = [Link]();
int seatCapacity = [Link]();[Link]();
double ticketRate = [Link]();
double theatreRating = [Link]();
boolean balconyAvailable = [Link]();
theatres[i] = new Theatre(theatreId, theatreName, seatCapacity,
ticketRate, theatreRating, balconyAvailable);
}
int newTheatreId = [Link]();
int newCapacity = [Link]();
[Link]();
String theatreCategory = findTheatreCategory(theatres, newTheatreId);
if(theatreCategory == null)
[Link]("There is no Theatre with the given Theatre ID");
else
[Link](theatreCategory);
Theatre[] newTheatres = searchTheatreByCategory(theatres, newCapacity);
if(newTheatres == null)
[Link]("Only low capacity theatres available");
else
for(Theatre theatre: newTheatres){
[Link]([Link]());
}
}
public static String findTheatreCategory(Theatre th[],int theatreId)
{
for(Theatre x:th)
{
if([Link]()==theatreId)
{
double tr=[Link]();
boolean ba=[Link]();
if(ba==true&&tr>4)
{
return "Ultra Premium";
}
else if(ba==true&&tr>=3&&tr<=4)
{
return "Premium";
}
else
return "Normal";
}
}
return null;
}
public static Theatre[] searchTheatreByCategory(Theatre[] th,int
seatCapacity)
{
List<Theatre> res=new ArrayList<>();
for(Theatre x:th)
{
if([Link]()>seatCapacity)
{
[Link](x);
}
}
if([Link]()==0)
return null;
[Link](res,new Sort());
Theatre res1[]=[Link](new Theatre[[Link]()]);
return res1;
}
}
class Sort implements Comparator<Theatre>
{
public int compare(Theatre obj1,Theatre obj2)
{
return (int)([Link]()-[Link]());
}
}
class Theatre
{
private int theatreId;
private String theatreName;
private int seatCapacity;
private double ticketRate,theatreRating;
private boolean balconyAvailable;
public Theatre(int theatreId,String theatreName,int seatCapacity,double
ticketRate,double theatreRating,boolean balconyAvailable)
{
[Link]=theatreId;
[Link]=theatreName;
[Link]=seatCapacity;
[Link]=ticketRate;
[Link]=theatreRating;
[Link]=balconyAvailable;
}
public int getTheatreId()
{
return theatreId;
}
public String getTheatreName()
{
return theatreName;
}
public int getSeatCapacity()
{
return seatCapacity;
}
public double getTicketRate()
{
return ticketRate;
}
public double getTheatreRating()
{
return theatreRating;
}
public boolean getBalconyAvailable()
{
return balconyAvailable;
}
}