Question: 2. Write a program, called HVV7-goals-cpp, that repeatedly (a) displays the game #, and (b) reads integer values from the user, which are the number
2. Write a program, called HVV7-goals-cpp, that repeatedly (a) displays the game #, and (b) reads integer values from the user, which are the number of goals and assists that a hockey player scores in a game. . The program should stop when a negative value is entered for either goals or assists. What type of loop would best fit here? See page 313 for assistance. .When done inputting, it should print the total number of goals, total number of assists, average number of goals (double value) and average number of assists (double value). . Additionally, it should print whether or not (display result in either case) the player had a hat trick (a game with 3 or more goals). A sample run might be (user input in bold): Game #1: Enter a number of goals: 0 Enter a number of assists: 0 #2: Game Enter a number of goals: 1 Enter a number of assists: 0 Game Enter a number of goals: 2 Enter a number of assists: 1 #3: Game Enter a number of goals: 0 Enter a number of assists: 3 #4: Game #5: Enter a number of goals: 4 Enter a number of assists: 1 Game #6: Enter a number of goals: 0 Enter a number of assists: 0 Game #7: Enter a number of goals: 2 Enter a number of assists:-3 Total Goals: Total Assists: s Average Goals: 1.28571 Average Assists: 0.714286 Yes, there was a hat trick! The text, line spacing and in-line spacing should match the sample outputs shown for both programs. Don't do any number formatting on the averages. Comment your programs appropriately (header, variables and control structures)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
