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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started