Activity 1.4.1.
public static String determineEventEligibility(int personAge, int yearsInGroup) { if (personAge > 60 && yearsInGroup >= 5) { return "Qualified"; } return "Not qualified"; }
- Correct!
public static String determineEventEligibility(int personAge, int yearsInGroup) { if (personAge > 60) { if (yearsInGroup >= 5) { return "Qualified"; } } return "Not qualified"; }
- Correct! The else statement in the original code was unnecessary and could be removed. Click on the Hint to see the truth table.
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 the truth table.
public static String determineEventEligibility(int personAge, int yearsInGroup) {
if (personAge > 60) {
if (yearsInGroup >= 5) {
return "Qualified";
} else {
return "Not qualified";
}
}
return "Not qualified";
}
Select all that apply.
Hint.
Here is the truth table. Compare the functionality of the given code blocks with the original code.
personAge > 60 | yearsInGroup >= 5 | Output |
true | true | "Qualified" |
true | false | "Not qualified" |
false | - | "Not qualified" |
false | - | "Not qualified" |