Activity 1.10.1.
public static String guessGame(int number) { if (number % 4 == 0) { return "Good guess!"; } else if (number % 7 == 0) { return "Good guess!"; } return "Try again"; }
- This code can be improved!
public static String guessGame(int number) { if (number % 4 == 0) { return "Good guess!"; } if (number % 7 == 0) { return "Good guess!"; } return "Try again"; }
- This code can be improved!
public static String guessGame(int number) { if (number % 4 == 0 || number % 7 == 0) { return "Good guess!"; } return "Try again"; }
- Correct!
public static String guessGame(int number) { if (number % 4 != 0 && number % 7 != 0) { return "Try again"; } return "Good guess!"; }
- Correct!
These code blocks are the same as the ones you saw in the previous question, and they all have the same functionality. Among these options which ones are preferable?