Question: Complete the following c + + code:aincluda Assignment You will be writing a program to score bowling for several players. Your job will be to

Complete the following c++ code:aincluda 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
You must use a vector to store all of the player names. All player names will be a single name.
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.
You must use an array or a vector to store each roll's value (see rubric below for more hints).
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.
You must use a For loop to input the roll values into the array/vector (whichever you choose for #3).
If the user types "done" before entering any names, output "No players were entered."
In the event of a tie, the first player (lowest vector index) to obtain the best or worst score is printed.
You can assume that the user will input valid scores. You do not need to perform error checking for invalid input. Hints
Collect ALL the pins knocked down for each roll before attempting to calculate the player's total score. It's much more difficult to calculate the total
score as you play, luckily, you are just calculating the score after the game is complete.
I suggest using a while(true) loop for the data collection. The word "done" can be the check to break you out of the loop. Inside the loop, you can
ask for the player's name, gather the rolls for the player, and calculate the total score for that player (and store it in scores). After you exit the
while(true) loop, see and print who won.
The players and scores vectors should be parallel vectors. players[i] should be a name and scores[i] should be that person's score. Each time you
iterate through the while(true) loop, you gathering data for a new person, so each of these vectors should get a push_back.
The array/vector to store each roll's value (#3 in restrictions) is something you will reuse for each person. It has a size of 21: 9 frames have 2 rolls
max, 10th frame has 3 rolls max. So (9*2)+3 is 21 total rolls. Once you calculate the person's final score (taken from data in this rolls array), you no
longer need the roll data for that person, so we can reuse it. If you don't use a roll (i.e. you get a strike so you skip the 2 nd roll for the frame), then
the "skipped" roll should just have a 0 for that index. For example, if rolls[0] is equal to 10, that means you got a strike on the first frame. Then
rolls[1] must be 0 since you won't have a second roll for frame 1.
When calculating the total score, you need to account for spares, strikes, double strikes [in frames 1-8 only], and your normal roll that's not any of
these. 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.
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 f
AEncludt
Wineluda
AEneludd
using namaspace td;
cort at andl;
1
rallinput;?
if xoli.
1
// Fro0d: input the last xall if notded
raturn playerholls;
int ealeulataplayartsara(cant vactar=int" tplayaxhalla) f
int playtrofeara =0;
adga cata: if thare is a daubla strika on 2 and 10, traat a lika a
1
//[ro0d: ealculate the frime sears
xatuxn playmxycaxa;
Z/ This line proventa the progran froe seg foulting if na playari mext
15(playymanas.anpty()) i
1
Ptahn tearad sue.,
*+
1
// ruod: print rusulty
int amin() I
thile (yru)i
titing inputstxing;
if (inputstring ---dano){f
hore: don't do any of the sunnary hase, axit the loap first
1
const yectarsint> playaxhalla = inputplayaraalla();
const int playerscora = calculataplayerscara(playurnalls);
// F000: stary the numa and scars
1
(throw funtim_-artar((Ynylitid input-);
printGanesumeary(playerhanes, playorscaran);
Complete the following c + + code:aincluda

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!