Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Principles Of Database Systems With Internet And Java Applications

Authors: Greg Riccardi

1st Edition

020161247X, 978-0201612479

More Books

Students also viewed these Databases questions

Question

gpt 4 9 9 .

Answered: 1 week ago