Write a program that will keep track of golf handicaps. To find a player's handicap, you will need to know the player's score, the course rating and the course slope.
Step 1 is to get a player to enter 5 scores. For this lesson we will assume all rounds were played at Wedgewood Country Club which has a course rating of 681. and a slope of 115. Your program should tell the player that he will enter 5 rounds from Wedgewood and you will calculate his handicap. You will need a loop to keep track of how many scores he's entered.
Step 2 is to find the players "Handicap Differential" for each score entered. The formula for this is: Handicap Differntial = (player's score - course rating) * 113 / slope. An example for Bob who scores a 98 at Wedgewood is: Handicap Differential = (98 - 68.1) * 113 / 115. Using this formula, Bob's handicap differential would be 29.38. You can do this in a module that is called within the loop after the score is entered.
Step 3 is to store the handicap differential in an array. This can also be done in a module.
Step 4 is to repeat steps 1 through 3 until the user has entered 5 scores and you have calculated 5 handicap differentials. This will end the loop that you set up to get 5 scores.
Step 5 is to find the average handicap differential. To do this you will need to loop through the handicap differential array and add all 5 values together into a 'total' variable. Once you have the total of the handicap differentials in a variable, you will then need to divide this variable by 5, giving you the average of the 5 handicap differentials. Once you have the average you will exit the loop.
Step 6 is to multiply the handicap differential by 0.96 and round it to a whole number. This will give you the players final handicap.
Step 7 - You will need to display the player's handicap and a message to the player depending on his handicap. If the handicap is >= 36, display "Your handicap is greater than the maximum allowed. You will play with a 36.4 handicap." If the handicap is <36 and > 18, display "Not bad, but there's room for improvement." If the handicap is <= 18, display "You might want to think about going professional.
Here is an example of final output.
"Hello Joe."
"Your handicap is 27."
"Not bad, but there's room for improvement."