Any hint on how to start writing the following program:
a golf game that allows the user to play one hole, a 280 metre par 5.
The game proceeds with the player choosing a club for each shot and then the program generates the distance hit for each shot and then updates the distance to the hole accordingly. Play proceeds until the ball is in the hole (distance to the hole is zero), and then the program informs the user of their score.
The player (user) has three clubs to choose from for each shot. Each club hits the ball a certain average distance, but the actual distance hit randomly varies between 80% and 120% of the average. The clubs, average distances (and ranges) are:
• Driver: 100m (Between 80m and 120m)
• Iron: 30m (Between 24m and 36m)
• Putter: 10m (Between 8m and 12m)
When the ball is inside 10m and the putter is used, the shot will be between 80% and 120% of the distance to the hole, not the club's distance. The minimum distance the putter can hit is 1m (no Om hits). All distances are whole numbers.
If an invalid club is chosen, this is counted as an air swing and the number of shots increases by one, but the ball doesn't get any closer.
The ball cannot be a negative distance to the hole. Whether it is in front of or behind the hole, it is still a positive distance to the hole.
The score is the number of shots taken to get the ball in the hole. The final output shows the number of shots taken and how this relates to par. Less than 5 (in this case) is "under par", equal to 5 is called "par", and more than 5 is "over par".