Question: Write a program that compiles some statistics about World Series winners from 1903-2012 (c++ !) Consult the Program 11 data code posted in this module.

Write a program that compiles some statistics about World Series winners from 1903-2012 (c++ !)

Consult the Program 11 data code posted in this module. One is a simple list of any team that won, and there are 29 teams in that list. The other is a list of all winners by year, and there are 104 years on file. Copy and paste the list of the year-by-year winners into an external file "winners.txt" for use in your program.

Use two parallel arrays for this project, one for the team names, and the other for how many times they've won the World Series. Initialize the integer array to all zeros. These are corresponding arrays, meaning the team that's in array teams[4], for example, is associated with the number of wins stored in the other integer array, e.g., wins[4].

Your program should be in three distinct steps:

1. Use a string array to store the names of the 29 teams. You may code this manually or read those 29 teams from a file and store them into the array.

2. Read the winners.txt file and every time a certain team has won, increment the corresponding index in the integer array. This means you have to search the array, and when there's a match, increment the corresponding array index in the other array.

3. Ask the user to enter 1 for Team x, 2 for Team y, ... , 26 for Team zz, in order to find out how many times they've won the WS. Present a beautifully-formatted menu. Then let the user know how many times that team has won the World Series.

The program should REPEAT until the user opts to (Q)uit.

============List of any team that won the WS 1903-2012========================== Anaheim Angels Arizona Diamondbacks Atlanta Braves Baltimore Orioles Boston Americans Boston Braves Boston Red Sox Brooklyn Dodgers Chicago Cubs Chicago White Sox Cincinnati Reds Cleveland Indians Detroit Tigers Florida Marlins Kansas City Royals Los Angeles Dodgers Milwaukee Braves Minnesota Twins New York Giants New York Mets New York Yankees Oakland Athletics Philadelphia Athletics Philadelphia Phillies Pittsburgh Pirates San Francisco Giants St. Louis Cardinals Toronto Blue Jays Washington Senators 

Here is my attempt at this so far:

#include

#include

#include

using namespace std;

int main() {

const int team_SIZE = 29;

string teams[team_SIZE];

int count = 0;

ifstream inputFile;

inputFile.open("winners.txt");

for (int i = 0; i < team_SIZE; i++)

{

getline(inputFile, teams[count]);

count++;

}

for (int i = 0; i < team_SIZE; i++)

getline(inputFile, teams[i]);

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!