Activity 1.8.1.
public static String isHighImpact(boolean isPeerReviewed, String journalName, int citationCount) { if (!isPeerReviewed) { return "Not high-impact."; } if (!isWellKnownJournal(journalName)) { return "Not high-impact."; } if (citationCount <= 50) { return "Not high-impact."; } return "High-impact!"; }
- This code can be improved!
public static String isHighImpact(boolean isPeerReviewed, String journalName, int citationCount) { if (isPeerReviewed) { if (isWellKnownJournal(journalName)) { if (citationCount > 50) { return "High-impact!"; } } } return "Not high-impact."; }
- This code can be improved!
public static String isHighImpact(boolean isPeerReviewed, String journalName, int citationCount) { if (isPeerReviewed && isWellKnownJournal(journalName) && citationCount > 50) { return "High-impact!"; } return "Not high-impact."; }
- Correct!
public static String isHighImpact(boolean isPeerReviewed, String journalName, int citationCount) { if (!isPeerReviewed || !isWellKnownJournal(journalName) || citationCount <= 50) { return "Not high-impact."; } else { return "High-impact!"; } }
- 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?