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's name is based on the actual strokes taken compared to par:

"Eagle": number of strokes is two less than par
"Birdie": number of strokes is one less than par
"Par": number of strokes equals par
"Bogey": number of strokes is one more than par

Given two integers that represent par and the number of strokes used, write a program that prints the appropriate score name. Print "Error" if par is not 3, 4, or 5.

Ex: If the input is:
4
3

Respuesta :

The program is an illustration of if conditional statement. The programming language is not stated; so, I will answer the question using Python.

The program in Python where comments are used to explain each line is as follows:

#This initializes the scores

scores = ["Eagle","Birdle","Par","Bogey"]

#This gets input for par

par = int(input())

#This gets input for stroke

stroke = int(input())

#This checks if par and stroke are between 3 and 5 (inclusive)

if (par >=3 and par <= 5) or (stroke >=3 and stroke <= 5):

#This calculates the difference between par and stroke

   diff = stroke - par  + 2

#This prints the corresponding score

   print(scores[diff])

#If par or stroke is out of range of 3 and 5

else:

#This prints error

   print("Error")

#At the end of the program, the appropriate score is printed.

See attachment for the program source code and the sample run

Read more about python programs at:

https://brainly.com/question/16917190

Ver imagen MrRoyal