Many thanks to Professor Bulko for allowing me to use this assignment.
Review the assignment guidelines.
Bowling is a popular past time. Granted, not as popular now as it was when I was in my teens.
To make bowling leagues more fun for beginners, bowlers are often assigned a handicap so that beginning bowlers still have a chance of winning a match against more experienced bowlers. The handicap is calculated based on the bowler's average score; the higher the average, the lower the handicap. For example, a bowler with an average of 100 may have a handicap of 80, and a bowler with an average of 150 may only have a handicap of 40. When the two bowlers compete against each other, their handicaps are added to their respective scores to determine the winner. The more experienced bowler typically still has an advantage (if they both bowl their averages exactly, the 150 + 40 = 190 will beat the 100 + 80 = 180) but the less experienced bowler has a better chance. If the 150 bowler bowls exactly 150, the 100 bowler need only bowl a 111 to win instead of a 151.
Algorithm:
Every bowling league may define the way handicap is calculated with their own methodology. However, most leagues typically use a formula such as the following:
handicap = (200 - average) * 80%
where the bowler's average (a floating-point number) is truncated to the next lower integer, and the handicap is also truncated to the next lowest integer.
For example: if a bowler in the above league had a 147.8 average, you would calculate their handicap as:
average = 147 (147.8 truncated towards negative infinity) handicap = (200 - average) * 80% = (200 - 147) * 80% = 53 * 80% = 42.4
which is then truncated towards negative infinity is 42. Note, we are only using the average of 3 games. Given that, we could never have an average of 147.8. We would have to increase the number of games we based the average on to get an average of 147.8.
Here is another example that shows what to do if the handicap is negative
average = 299 handicap = (200 - average) * 80% = (200 - 299) * 80% = -99 * 80% = -79.2 = -80 when truncated towards negative infinity
Clearly you will want to use floor division when determining the average score and the handicap.
Assignment:
Write a complete Python program that calculates a bowler's average and handicap after three games. Prompt the user to enter three bowling games (integers between 0 and 300 inclusive) one at a time, and calculate the bowler's average and handicap. Print out the average and handicap, truncated to integers.
Expected output:
Format your output so that, if you were to use sample name of Mike and the input scores of 143, 128, and 162, your output would look exactly like the following. The input is bolded. The input does not appear in bold when you run the program.
Enter your name: Mike Enter Game 1: 143 Enter Game 2: 128 Enter Game 3: 162 Mike's average is: 144 Mike's handicap is: 44
Of course, your program should run regardless of what values were input, as long as the game scores are integers. (Your program does not need to verify that the numbers are valid bowling scores, which in ten pin bowling range from 0 to 300.Nor do you need to verify the user actually enters an integer. If the user enters a value that is not an integer the program should crash, but we will not test this.)
More sample input and output in this file.
Recall, you must include and fill out the header for the assignment and place it at the top of the program. Replace any items in <> with the proper information and delete the <>.
# File: bowling.py
# Description:
<A DESCRIPTION OF YOUR PROGRAM>
# Assignment Number: 3
#
# Name: <YOUR
NAME>
# EID: <YOUR EID>
# Email: <YOUR EMAIL>
# Grader: <YOUR
GRADER'S NAME Mayra OR Risha>
# Slip days used this assignment: <#>
#
# On my
honor, <YOUR NAME>, this programming assignment is my own work
# and I have
not provided this code to any other student.
Recall, your grader is assigned based on your last name. See the course syllabus for your assigned grader.