logo

UTK Notes


Lab 07: Bowling Lab

Assignment

You will be writing a program to score bowling for several players. Your job will be to ask for players and their scores, then add up their score. When all players have been entered, the user will type “done”. Then, your program will tally up the worst and best player and output who won and who lost the game.

Restrictions / Hints

  1. You must use a vector to store all of the player names. All player names will be a single name.
  2. You must use another vector to store the total score for each player. You must calculate the total score for each player after all rolls have been entered.
  3. You must use an array or a vector to store each roll’s value (see rubric below for more hints).
  4. The number of rolls is variable depending on whether the player threw a strike (knocked down 10 pins in one roll), spare, or neither. Please see “Scoring Bowling” below.
  5. You must use a For loop to input the roll values into the array/vector (whichever you choose for #3).
  6. If the user types “done” before entering any names, output “No players were entered.”
  7. In the event of a tie, the first player (lowest vector index) to obtain the best or worst score is printed.
  8. You can assume that the user will input valid scores. You do not need to perform error checking for invalid input.

Scoring Bowling

Please see: https://www.wikihow.com/Score-Bowling for a step by step tutorial.

This YouTube video also is a good tutorial for scoring bowling: https://www.youtube.com/watch?v=-4wNjb9F1mo

Bowling is *NOT* just adding up all the pins knocked down! It is more complicated when spares and strikes are involved.

Test Cases

Help yourself by coming up with your own test cases. What are the “routes” our algorithm can take? Make sure to have a test for each “route”.

To check your program’s score against a variety of test cases, use https://www.bowlinggenius.com/ to verify your program’s score.

Examples

Note that John (in the first game below) scored a perfect score of 300 with all strikes. Note that the second game has no players.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Enter player's name (done for no more players): John
Enter score for frame 1, roll 1: 10
Enter score for frame 2, roll 1: 10
Enter score for frame 3, roll 1: 10
Enter score for frame 4, roll 1: 10
Enter score for frame 5, roll 1: 10
Enter score for frame 6, roll 1: 10
Enter score for frame 7, roll 1: 10
Enter score for frame 8, roll 1: 10
Enter score for frame 9, roll 1: 10
Enter score for frame 10, roll 1: 10
Enter score for frame 10, roll 2: 10
Enter score for frame 10, roll 3: 10
Enter player's name (done for no more players): Cheryl
Enter score for frame 1, roll 1: 8
Enter score for frame 1, roll 2: 1
Enter score for frame 2, roll 1: 0
Enter score for frame 2, roll 2: 9
Enter score for frame 3, roll 1: 2
Enter score for frame 3, roll 2: 8
Enter score for frame 4, roll 1: 10
Enter score for frame 5, roll 1: 6
Enter score for frame 5, roll 2: 3
Enter score for frame 6, roll 1: 7
Enter score for frame 6, roll 2: 0
Enter score for frame 7, roll 1: 5
Enter score for frame 7, roll 2: 2
Enter score for frame 8, roll 1: 10
Enter score for frame 9, roll 1: 0
Enter score for frame 9, roll 2: 6
Enter score for frame 10, roll 1: 2
Enter score for frame 10, roll 2: 8
Enter score for frame 10, roll 3: 10
Enter player's name (done for no more players): done

John scored 300.
Cheryl scored 122.
Cheryl did the worst by scoring 122.
John won the game by scoring 300.
1
2
Enter player's name (done for no more players): done
No players were entered.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Enter player's name (done for no more players): John
Enter score for frame 1, roll 1: 8
Enter score for frame 1, roll 2: 1
Enter score for frame 2, roll 1: 0
Enter score for frame 2, roll 2: 9
Enter score for frame 3, roll 1: 2
Enter score for frame 3, roll 2: 8
Enter score for frame 4, roll 1: 10
Enter score for frame 5, roll 1: 6
Enter score for frame 5, roll 2: 3
Enter score for frame 6, roll 1: 7
Enter score for frame 6, roll 2: 0
Enter score for frame 7, roll 1: 5
Enter score for frame 7, roll 2: 2
Enter score for frame 8, roll 1: 10
Enter score for frame 9, roll 1: 0
Enter score for frame 9, roll 2: 6
Enter score for frame 10, roll 1: 2
Enter score for frame 10, roll 2: 8
Enter score for frame 10, roll 3: 10
Enter player's name (done for no more players): done

John scored 122.
John did the worst by scoring 122.
John won the game by scoring 122.

Plagiarism

Please review the plagiarism policy on the syllabus.

Submission

Complete the lab so your output matches the output in the examples and follows the grading rubric below.

Submit your bowling.cpp file. This MUST compile, or it will not be graded.