Question: Write a program, goals.cpp , that repeatedly reads integer values which are the number of goals and assists that a hockey player scores in a

Write a program, goals.cpp, that repeatedly reads integer values 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. 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):

Enter a number of goals: 0

Enter a number of assists: 0

Enter a number of goals: 1

Enter a number of assists: 0

Enter a number of goals: 2

Enter a number of assists: 1

Enter a number of goals: 0

Enter a number of assists: 3

Enter a number of goals: 4

Enter a number of assists: 1

Enter a number of goals: 0

Enter a number of assists: 0

Enter a number of goals: 2

Enter a number of assists: -3

Total Goals: 7

Total Assists: 5

Average Goals: 1.16667

Average Assists: 0.833333

Yes, there was a hat trick!

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 Databases Questions!