Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

6.23 zyLab: Golf Scores Golf scores record the number of strokes used to get the

ID: 3909988 • Letter: 6

Question

6.23 zyLab: Golf Scores Golf scores record the number of strokes used to get the ball in the hole. The expected number of strokes varies from hole to hole and is called par (i.e. 3, 4 or 5). Each score has a cute name based one the actual strokes taken compared to par. Return-Eagle" if strokes is two less than par. Return "Birdie" if strokes is one less than par. Return Par if par matches strokes exactly. Return "Bogey if strokes is one more than par. Return "Error" if par is not 3,4 or 5 LAB ACTIVTY 623.1: zyLab: Golf Scores 0/5 Main.java Load default template... 1 public class Main 3 public String golfScore int par, int strokes) 4 I this method not used but needed for testing 8 public static void main(String[ args) t 10 1

Explanation / Answer

public String golfScore(int par, int strokes) { if(par == 3 || par == 4 || par == 5) { int score = strokes - par; if(score == -2) { return "Eagle"; } else if(score == -1) { return "Birdie"; } else if(score == 0) { return "Par"; } else if(score == 1) { return "Bogey"; } else { return "Error"; } } else { return "Error"; } }