import java.util.*;
class RailwayInfo{
public static boolean isGoodTrain(String name,
int avgSpeed,int totalDistance,
boolean isPassengerHappy,
int noOfStation,String[] typeOfCoach){
int ratio=totalDistance/noOfStation;
List data=Arrays.asList(typeOfCoach);
if(name.length()>1 && (name.endsWith("Mail")||name.endsWith("Express"))
&&(avgSpeed>70)
&& (totalDistance>700)
&& ((name.contains("Mail")&& ratio==50)||
(name.contains("Express") && ratio==100))
&& (isPassengerHappy==true) &&
((totalDistance>=1000 && totalDistance<=1500 )&& (data.contains("3AC")))
|| (totalDistance>=1500 && data.contains("2AC"))){
System.out.println("Valid..");
return true;
}
return false;
}
public static void main(String[] args){
System.out.println(isGoodTrain("VishskMail",1000,1000,true,20,new String[]{"2AC","3AC"}));
}
}
class RailwayInfo{
public static boolean isGoodTrain(String name,
int avgSpeed,int totalDistance,
boolean isPassengerHappy,
int noOfStation,String[] typeOfCoach){
int ratio=totalDistance/noOfStation;
List data=Arrays.asList(typeOfCoach);
if(name.length()>1 && (name.endsWith("Mail")||name.endsWith("Express"))
&&(avgSpeed>70)
&& (totalDistance>700)
&& ((name.contains("Mail")&& ratio==50)||
(name.contains("Express") && ratio==100))
&& (isPassengerHappy==true) &&
((totalDistance>=1000 && totalDistance<=1500 )&& (data.contains("3AC")))
|| (totalDistance>=1500 && data.contains("2AC"))){
System.out.println("Valid..");
return true;
}
return false;
}
public static void main(String[] args){
System.out.println(isGoodTrain("VishskMail",1000,1000,true,20,new String[]{"2AC","3AC"}));
}
}
Comments
Post a Comment