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

Create a java program array with a double array named handicap that will contain

ID: 3779176 • Letter: C

Question

 Create a java program array with a double array named handicap that will contain the handicap that will contain the handicap index for each of the six players (6 element array).  2. You must use a method to calculate the handicap index for each player Method: calculateHandicap  Argument: an int array containing one players scores (Note: the course rating, and the slope rating  have been definded as Class Variables so these two variables may be used in the method)  Method Body: Step through the array and calculate the players average score. Do not hardcode 10 in your for loop header.  User player.length instead, assuming the int array is called.  Player: Now,use this average score to calculate the players average differential. Multiply the average differential by .96 to get the Handicap index.  Return Value: double - the Handicap index 3. Using a for loop, output each player number and the players handicap to 1 decimal place (see Sample Output). You must use System.out.printf or DecimalFormat to control for the number of decimal places. Do Not hardcode 6 in your for-loop header - use handicap.length instead. 4. Now,prompt the user for each of the six players new scores for new round of golf (winner takes all!). Use this score to populate a second array named netScore, which will contain the adjusted scores of the players(i.e, the score minus the handicap).Use netScore.length in your for-loop header (see Sample Output). 5. Step through netScore and determine which player has won the game . Again, use netScore.length in your for-loop header. The Lowest score wins! 6. Output both the net score (to 1 decimal place) and the player number of who won the round. That is, the element and index (the index repents the players). the course rating, which is a number generally between 67 and 77 that is used to measure the average "good score" on a course by a scratch golfer (plays to a course handicap of 0). the slope rating, which is a number between 55 and 155that describes the relative difficulty of a course for a bogey golfer (golfer who averages 1 bogey per hole) compared to a scratch golfer. These two  numbers are used to calculate a players handicap differntial, which is used to adjust a players score in relation to poar, according to the course and slope and ratings. The slopes rating for a golf course of average diffculty is 113.  Handicap Differntial= ((Gross Score-Course Rating)*113)/Slope Rating Handicap Index = (Average of 10 best differentials )*0.96 Net Score = Gross Score - Handicap   The program below contains 10 best scores of 6 players, the course rating and, the slope rating. From these scores, determine the players handicaps.  Then assuming these six players have just completed a tournment, prompt for thier gross score from the golf round.  Determine their net scores and output the winner (note that the lowest score wins in golf).   import java.util.*; import java.text.*; public class GolfHandicap {         //Class Variables         public static double slope = 119;         public static double course = 69.3;                  //Main Method         public static void main(String[] args) {                 int [] player1 = {91,89,90,90,85,87,95,81,91,89};                 int [] player2 = {85,83,83,88,80,85,85,90,86,87};                 int [] player3 = {79,78,85,76,79,75,74,77,75,78};                 int [] player4 = {82,80,82,82,87,79,81,80,81,84};                 int [] player5 = {95,98,94,95,97,98,99,97,99,96};                 int [] player6 = {74,77,78,73,71,75,75,71,73,80};         }                  //Function calculateHandicap } 

Explanation / Answer

import java.util.*; import java.text.*; public class GolfHandicap { //Class Variables public static double slope = 119; public static double course = 69.3; //double array for sotring handicap index values public static double[] handicap = new double[6]; //Main Method public static void main(String[] args) { int [] player1 = {91,89,90,90,85,87,95,81,91,89}; int [] player2 = {85,83,83,88,80,85,85,90,86,87}; int [] player3 = {79,78,85,76,79,75,74,77,75,78}; int [] player4 = {82,80,82,82,87,79,81,80,81,84}; int [] player5 = {95,98,94,95,97,98,99,97,99,96}; int [] player6 = {74,77,78,73,71,75,75,71,73,80}; //calculating handicap index for each player handicap[0] = calculateHandicap(player1); handicap[1] = calculateHandicap(player2); handicap[2] = calculateHandicap(player3); handicap[3] = calculateHandicap(player4); handicap[4] = calculateHandicap(player5); handicap[5] = calculateHandicap(player6); //printing out handicap index of each player for(int i=0; i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote