import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
TravelAgencies []agencies=new TravelAgencies[4];
for(int i=0;i<4;++i)
{
int r=sc.nextInt();
sc.nextLine();
String an=sc.nextLine();
String pt=sc.nextLine();
int p=sc.nextInt();
boolean ff=sc.nextBoolean();
agencies[i]=new TravelAgencies(r, an, pt, p, ff);
}
System.out.println(findAgencyWithHighestPackagePrice(agencies));
int regNo=sc.nextInt();
sc.nextLine();
String packageType=sc.nextLine();
TravelAgencies res=agencyDetailsForGivenIdAndType(agencies, regNo, packageType);
if(res!=null)
System.out.println(res.agencyName+":"+res.price);
else
System.out.println(res);
}
public static int findAgencyWithHighestPackagePrice(TravelAgencies[] agencies)
{
//method logic
int max=agencies[0].price;
for(int i=0;i<agencies.length;++i)
{
if(agencies[i].price>max)
{
max=agencies[i].price;
}
}
return max;
}
public static TravelAgencies agencyDetailsForGivenIdAndType(TravelAgencies[] agencies, int regNo, String packageType)
{
TravelAgencies out=null;
for(int i=0;i<agencies.length;++i)
{
if(agencies[i].flightFacility==true && agencies[i].regNo==regNo &&agencies[i].packageType.equalsIgnoreCase(packageType))
{
out=agencies[i];
}
}
return out;
}
}
class TravelAgencies
{
int regNo;
String agencyName;
String packageType;
int price;
boolean flightFacility;
TravelAgencies(int r,String an,String pt,int p,boolean ff)
{
regNo=r;
agencyName=an;
packageType=pt;
price=p;
flightFacility=ff;
}
}
No comments:
Post a Comment