Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 11 The Ultimate Database For Cloud Analytics And Mobile

Authors: John Campbell, Chris Crone, Gareth Jones, Surekha Parekh, Jay Yothers

1st Edition

1583474013, 978-1583474013

More Books

Students also viewed these Databases questions