Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A local baseball league has asked you to write a program for tracking scores for

ID: 3840608 • Letter: A

Question

A local baseball league has asked you to write a program for tracking scores for 4 teams. Each team played 5 games. Write a program that asks the league official to enter the 5 scores for each team. Your program has to use arrays. You can use 4, 1-dimensional arrays, one array per team or you could use 1, 2-dimensional array where each column holds a team’s scores. The program should determine which team had the highest sum total of scores. The output of the program should display all scores for each team and the team # that has the highest total sum of scores. First, describe your algorithm using pseudocode.

Translate the pseudocode into a C++ program. You must comment your program including comments at the top of the file that explains what the program does and comments for every line of code that explains what is happening for the line of code. Apply troubleshooting and testing strategies to ensure your code compiles, runs, and provides accurate results.

Explanation / Answer

//The program will compute baseball statistics

#include <iostream>
#include <cmath>

using namespace std;

int main()
{
int id, wins, losses, nd, totalgames, gamesremaining, wiptotal, gp=0;
double winavg;

cout << "Enter team's' id: ";
cout << "To stop, enter a negative value as the teams id number> ";
cin >> id;
while (id>=0) {
cout << "Enter number of wins: ";
cin >> wins;
cout << "Enter number of losses: ";
cin >> losses;
cout << "Enter number of no decisions: ";
cin >> nd;
cout << "Enter teams winning average: ";
cin >> winavg;

gp++;


cout << "team " << id << endl;
cout << wins << "wins" << losses << "losses" << nd << "no decision" << endl;
}

totalgames=wins + losses + nd;

cout << "Total number of games played is: " << totalgames << endl;

gamesremaining=25-totalgames;

if (totalgames==25)
cout << "The teams season is finisheed" << endl;

else
cout << "Print gamesremaining" << endl;

cout << "The number of games remaining is: " << gamesremaining << endl;

return 0;
}

// The program will compute the teams winning average and wiptotal

{
      
double winavg;

cout.setf (ios::fixed, ios::floatfield);
cout.precision (4);

winavg=wins/totalgames;

cout << "Teams winning average is: " << winavg << endl;


if (nd>=wins)
cout << "Number of games with no decision is greater than or equal to number of wins" << endl;

else (nd<losses)
cout <<"Number of games with no decision is not greater than number of losses" << endl;


wiptotal=wins + nd - (2 * losses);

cout << "The wip total is: " << wiptotal << endl;


cout << "We processed " << gp << "teams << endl;"
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote