Activity 1.8.1.
- 28
- Correct! guessGame1(28) prints "Good guess" twice but guessGame2(28) prints "Good guess" only once!
- 16
- Not Correct! Both guessGame1(16) and guessGame2(16) print "Good guess" once.
- 56
- Correct! guessGame1(56) prints "Good guess" twice but guessGame2(56) prints "Good guess" only once.
- 23
- Not Correct! Neither guessGame1(23) nor guessGame2(23) prints anything. So for this input both functions have the same bahavior.
Consider the following two functions (guessGame1() and guessGame2()). For which input(s) do these functions show different behavior?
public static void guessGame1(int number) {
if (number % 4 == 0) {
System.out.println("Good guess!");
}
if (number % 7 == 0) {
System.out.println("Good guess!");
}
}
public static void guessGame2(int number) {
if (number % 4 == 0 || number % 7 == 0) {
System.out.println("Good guess!");
}
}