Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++ ,Write a program that accepts as input the results of sports matches and calculates some statistics. Details The results are entered by the

In C++ ,Write a program that accepts as input the results of sports matches and calculates some statistics.

Details The results are entered by the console. For example, "5: 2 Toronto" means that your team has 5 goals and the opponent (Toronto) has 2. Your program must allow you to enter an arbitrary number of games, but until you discover the containers C ++ standard, you can use tables whose size is set to 100 elements.

The user signals the end of the inputs by entering a negative number. After the input is complete, the program compiles the results, calculates some statistics (see below) and prints the results to the console.

Instructions Create a source file named scores.cpp. For this first assignment, this will be the only file.

Include standard header files for input-output (iostream) and strings.

In the hand routine, write a loop that accepts a match from the user and adds each score and opponent team to a vector. The loop ends if the input is negative. Do not save the negative score.

Still in the hand routine, write a loop that

calculate the number of wins, losses and draws for your team,

calculates the total number of goals (for and against),

calculates the goals average (for and against) per match.

displays the match for which your team won (and lost) with the highest number of goals (and the lowest number of goals) with the name of the opponent for that match. Note: if there are several such matches, simply choose one reasonably, and

finally, displays statistics and match results. See below for an example.

View the results in an organized and readable way at the console.

Example

Here is an example of the execution of your program:

5: 2 Toronto 7: 4 Montreal 1: 4 Winnipeg 3: 2 LA -1 Wins / Draws / Losses: 3: 0: 1 Goals: 16:12 Average number of goals scored: 4.0 Highest win: 7: 4 Montreal Largest loss: 1: 4 Winnipeg Games: 5: 2 Toronto 7: 4 Montreal 1: 4 Winnipeg 3: 2 LA

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

Advances In Databases And Information Systems 22nd European Conference Adbis 2018 Budapest Hungary September 2 5 2018 Proceedings Lncs 11019

Authors: Andras Benczur ,Bernhard Thalheim ,Tomas Horvath

1st Edition

3319983970, 978-3319983974

More Books

Students also viewed these Databases questions

Question

what does it mean by pay yourself first in money matters

Answered: 1 week ago