217k views
0 votes
Create a program that asks the user to enter their golf scores for a 9-hole course. you will create a function that will pass the array to the definition and compute and display their total so that they can determine if they won the match at the end of the game.

1 Answer

4 votes

Final answer:

The question asks for a program that asks the user to enter their golf scores for a 9-hole course and then computes and displays their total. This is a programming task that falls under the Computers and Technology subject.

Step-by-step explanation:

The question asks for a program that asks the user to enter their golf scores for a 9-hole course and then computes and displays their total. This is a programming task that falls under the Computers and Technology subject. Since the question mentions passing an array to a function, it indicates the use of programming concepts.

To create this program, you can use a loop to prompt the user for each score and store them in an array. Then, create a function that takes the array as an argument, calculates the total score, and displays it to the user. Here is a Python example:

scores = []

for i in range(9):
score = int(input('Enter score for hole {}: '.format(i+1)))
scores.append(score)


def compute_total(scores):
total = sum(scores)
print('Total score:', total)


compute_total(scores)

User Cassiomolin
by
8.9k points