Activity 1.23.1.
canPlayGolf("Rainy", 50, false)
canPlayGolf("Sunny", 70, false)
canPlayGolf("Sunny", 50, true)
canPlayGolf("Sunny", 40, false)
canPlayGolf("Overcast", 80, true)
canPlayGolf("Sunny", 70, true)
canPlayGolf("Rainy", 30, true)
canPlayGolf("Rainy", 70, false)
public static boolean canPlayGolf(String weather, int humidity, boolean isWindy) { if (weather.equals("Sunny") && humidity < 60 && !isWindy) { return true; } return false; }
- Correct!
public static boolean canPlayGolf(String weather, int humidity, boolean isWindy) { if (!weather.equals("Sunny") || humidity >= 60 || isWindy) { return false; } return true; }
- Correcr!
public static boolean canPlayGolf(String weather, int humidity, boolean isWindy) { return weather.equals("Sunny") && humidity < 60 && !isWindy; }
- Correct!
Look at the first code block. Which of the following options have the same functionality as it (i.e., they produce the same output for the same inputs)? You can check the Hint for some input examples.
public static boolean canPlayGolf(String weather, int humidity, boolean isWindy) {
if (weather.equals("Sunny")) {
if (humidity < 60) {
if (isWindy == false) {
return true;
}
}
}
return false;
}
Hint.
You can use the following test cases to compare the code blocks’ functionality.
Select all that apply.