Must accepts "Maestro Cards"
Tax for bike should be less than 15
Total number of lanes is more than 10
Must provides monthly pass
Write a method:
boolean isGoodTollBridge(String[] cardsAccepted, String[] tollTax, boolean hasMonthlyPass, int numberOfLanes);
String[] cardsAccepted A String array of names of card types accepted for payment of toll tax, it can be null if the toll does not accept any card
String[] tollTax A String array of toll tax chart (say “Train : 300â€Â,â€ÂBullCart : 10â€Â)
boolean hasMonthlyPass This parameter defines whether there is any monthly pass available or not
int numberOfLanes This parameter defines the number of lanes for each side
Answer / Aditya Vikram Singh
Here's the implementation in Java:
```
public boolean isGoodTollBridge(String[] cardsAccepted, String[] tollTax, boolean hasMonthlyPass, int numberOfLanes) {
boolean isGood = false;
if (cardsAccepted != null && Arrays.asList(cardsAccepted).contains("Maestro")) {
if (Arrays.stream(tollTax).anyMatch(tax -> Integer.parseInt(tax.split(":")[1]) < 15)) {
if (numberOfLanes > 10) {
if (hasMonthlyPass) {
isGood = true;
}
}
}
return isGood;
}
| Is This Answer Correct ? | 0 Yes | 0 No |
What are proxy objects in c++?
How to construct muliton object
What does namespace mean in c++?
What is a protocol class?
Describe protected access specifiers?
When the constructor of a base class calls a virtual function, why doesn't the override function of the derived class gets called?
Explain differences between new() and delete()?
Write a corrected statement in c++ so that the statement will work properly. if (x = y) x = 2*z;
Is python better than c++?
Differentiate between the manipulator and setf( ) function?
5. Can inline functions have a recursion?
What is a storage class?