QuestionQuestion

You’ve been hired by Tickled Tigers to write a C++ console application that tracks scoring for Detroit Tiger baseball games. The season opener is today and they are playing the Pittsburgh Pirates. Since it is raining today, the game will only last five innings.

Declare two integer arrays to hold the scores for each team by inning. Note that for this application, it is easier to set up the loops if the score in an inning matches its array index. Declare the arrays to hold six values each but simply ignore the zero (first) index in both arrays.

Prompt the user for the number of runs scored by each team in each inning, and store the values in the correct arrays and at the correct spots. After getting the runs scored for an inning, print the box score through the number of innings played so far. A box score shows the runs scored by each team in each inning and the overall score. After the five innings, determine and print which inning each team scored the most runs.

Create and use the following functions:

● int teamScore(int runs[], int inning) loops through a team array and returns the runs scored through the given inning.

● int teamHigh(int runs[]) loops through a team array and returns the inning in which the most runs were scored by that team. If there is more than inning with a high, then return the first one.

● void printScore(int runsThem[], int runsUs[], int inning) prints a box score message, an underline, column headings, scores for the Pirates, and then scores for the Tigers.

Welcome to Tickled Tigers
-------------------------

Inning 1
Enter Pirates runs: 0
Enter Tigers runs: 2

Box score after 1 inning
--------------------------------
Team       1
Pirates    0   0
Tigers    2   2

Inning 2
Enter Pirates runs: 2
Enter Tigers runs: 3

Box score after 2 innings
--------------------------------
Team       1   2
Pirates    0   2   2
Tigers    2   3   5

Inning 3
Enter Pirates runs: 1
Enter Tigers runs: 0

Box score after 3 innings
--------------------------------
Team       1   2   3
Pirates    0   2   1   3
Tigers    2   3   0   5

Inning 4
Enter Pirates runs: 0
Enter Tigers runs: 4

Box score after 4 innings
--------------------------------
Team       1   2   3   4
Pirates    0   2   1   0   3
Tigers    2   3   0   4   9

Inning 5
Enter Pirates runs: 1
Enter Tigers runs: 0

Box score after 5 innings
--------------------------------
Team       1   2   3   4   5
Pirates    0   2   1   0   1   4
Tigers    2   3   0   4   0   9

Team high innings
Pirates: 2
Tigers: 4

End of Tickled Tigers

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

#include <cstdlib>
#include <iostream>
#include <iomanip>

using namespace std;

int teamScore(int runs[], int inning);
int teamHigh(int runs[]);
void printScore(int runsThem[], int runsUs[], int inning);

int main(int argc, char** argv) {

    /**
    * Declare two integer arrays to hold the scores for each team by inning.
    * Note that for this application, it is easier to set up the loops
    * if the score in an inning matches its array index.
    * Declare the arrays to hold six values each but simply ignore the
    * zero (first) index in both arrays.
    */

    int pirates [6];
    int tigers [6];

    for (int i = 0; i < 6; i++) {
       pirates[i] = 0;
       tigers[i] = 0;
    }


    cout << "Welcome to Tickled Tigers\n";
    cout << "-------------------------\n";


    for (int i = 1; i < 6; i++) {
       cout << "Inning " << i << "\n";
       cout << "Enter Pirates runs: ";
       cin >> pirates[i];
       cout << "Enter Tigers runs: ";
       cin >> tigers[i];
       cout << "\n";

       printScore(pirates, tigers, i);
    }...

By purchasing this solution you'll be able to access the following files:
Solution.zip.

$20.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats