TeamsAnaheim AngelsArizona DiamondbacksAtlanta BravesBaltimore OriolesBoston AmericansBoston BravesBoston Red SoxBrooklyn DodgersChicago CubsChicago White SoxCincinnati RedsCleveland IndiansDetroit...




Teams



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





Iterate through the Teams.txt file and store the contents of the Teams.txt file into a string



vector named teams. This means the first team should be stored in the first index of the



vector, the second team should be stored in the second index of the vector, and so on.





So the teams vector should be as follows:






teams[0] = “Anaheim Angels”



teams[1] = “Arizona Diamondbacks”



teams[2] = “Atlanta Braves”



teams[3] = “Baltimore Orioles” etc.









2. Iterate through the Winners.txt file and store the contents of the Winners.txt file into a



string vector named winners. This means the first team should be stored in the first index



of the vector, the second team should be stored in the second index of the vector, and so



on.



Boston Americans



New York Giants



Chicago White Sox



Chicago Cubs



Chicago Cubs



Pittsburgh Pirates



Philadelphia Athletics



Philadelphia Athletics



Boston Red Sox



Philadelphia Athletics



Boston Braves



Boston Red Sox



Boston Red Sox



Chicago White Sox



Boston Red Sox



Cincinnati Reds



Cleveland Indians



New York Giants



New York Giants



New York Yankees



Washington Senators



Pittsburgh Pirates



St. Louis Cardinals



New York Yankees



New York Yankees



Philadelphia Athletics



Philadelphia Athletics



St. Louis Cardinals



New York Yankees



New York Giants



St. Louis Cardinals



Detroit Tigers



New York Yankees



New York Yankees



New York Yankees



New York Yankees



Cincinnati Reds



New York Yankees



St. Louis Cardinals



New York Yankees



St. Louis Cardinals



Detroit Tigers



St. Louis Cardinals



New York Yankees



Cleveland Indians



New York Yankees



New York Yankees



New York Yankees



New York Yankees



New York Yankees



New York Giants



Brooklyn Dodgers



New York Yankees



Milwaukee Braves



New York Yankees



Los Angeles Dodgers



Pittsburgh Pirates



New York Yankees



New York Yankees



Los Angeles Dodgers



St. Louis Cardinals



Los Angeles Dodgers



Baltimore Orioles



St. Louis Cardinals



Detroit Tigers



New York Mets



Baltimore Orioles



Pittsburgh Pirates



Oakland Athletics



Oakland Athletics



Oakland Athletics



Cincinnati Reds



Cincinnati Reds



New York Yankees



New York Yankees



Pittsburgh Pirates



Philadelphia Phillies



Los Angeles Dodgers



St. Louis Cardinals



Baltimore Orioles



Detroit Tigers



Kansas City Royals



New York Mets



Minnesota Twins



Los Angeles Dodgers



Oakland Athletics



Cincinnati Reds



Minnesota Twins



Toronto Blue Jays



Toronto Blue Jays



Atlanta Braves



New York Yankees



Florida Marlins



New York Yankees



New York Yankees



New York Yankees



Arizona Diamondbacks



Anaheim Angels



Florida Marlins



Boston Red Sox



Chicago White Sox



St. Louis Cardinals



Boston Red Sox



Philadelphia Phillies



New York Yankees



San Francisco Giants



St. Louis Cardinals



San Francisco Giants





So the winners vector should be as follows:



winners[0] = “Boston Americans”



winners[1] = “New York Giants”



winners[2] = “Chicago White Sox”



winners[3] = “Chicago Cubs”



etc.






3. Using the teams vector, display all of the teams (one team per line) on the console screen.






4. Prompt the user for the name of a team to check world series wins for. Using the winners



vector, count how many times the team entered by the user won, and display this on the



screen.






At a minimum, you should have the following functions:






- A function to read the contents of the Teams.txt file and store it into the teams vector*.






- A function to read the contents of the Winners.txt file and store it into the winners vector*.






- A function to display all of the teams on the console screen using the teams vector (not the



teams file).






- A function to prompt the user for the team that they want to check world series wins for.






- A function to count how many times the team entered by the user won the world series using



the winners vector (not the winners file).






- A function to display how many times the team entered by the user won the world series.















*These two functions can actually be combined into one function with good usage of function parameters. This is not required, but you are encouraged to try and implement it this way. The idea is that the logic between these functions is exactly the same: read the contents of the teams/winners file into the teams/winners vector. This is why it’s possible to have one general read function that will work for both teams and winners, rather than having two different functions with almost identical code. To implement the function in this manner the vector itself will need to be passed to the function (see below). You will also need to pass in a second argument so that inside of the function you can distinguish between teams and winners (for example, so you can open the correct file to read from).



The second argument could be a number of different things: a string that stores either the word “teams” or winners”, a boolean (e.g., true = teams and false = winners), a char, an integer, etc. Again, this is optional and not required.






The teams and winners vectors should be declared inside of main, and then they need to be passed to the appropriate functions by reference (if the function changes the vector) or constant reference (if the function does NOT change the vector). For example: the vector teams is defined in main. It is then passed (by reference) to the function read_teams_file(), which builds the teams vector from the teams file. Then back in main, main calls the function display_teams(), passing in the teams vector (by constant reference). The changes made to the teams vector inside of read_teams_file() are reflected inside of display_teams(). This is because there is only ONE teams vector, which was defined in main. The other functions that use the vector, such as read_teams_file() and display_teams(), are referencing that same vector.



There should be absolutely NO global variables used anywhere in this assignment. Everything should be declared locally in a function and passed as function arguments when appropriate.





Sample Run 1:



The following teams have won the World Series at least once




Nov 03, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here