Code two functions to fill an array with the names of every World Series winning team from 1903 to 2020, then output each World Series winner and the number of times the team won the championship

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Code two functions to fill an array with the names of every World Series winning team from 1903 to 2020, then output each World Series winner and the number of times the team won the championship.  The input file is attached, along with a main function and screen print. Please note team names that include two words, such as Red Sox, have an underscore in place of the space. This enables you to use the extraction operator with a single string variable. 

My program is not working can you help me figure out who to make it run?

It needs to contain these specific things 

  1. Code a function to fill an empty array
  2. Fill an array from an input file
  3. Search the array for specific elements
  4. Output specific array elements as part of a string
  5. Use a for loop to step through an array
  6. Use a for loop to count occurrences in an array
  7. Use a conditional statement within a for loop used to process an array
  8. Use input stream objects
  9. Use string objects

I attached the world series winners list and a preview of how the program should look

#include <iostream>
#include <fstream>
#include<string>
using namespace std;
void fill (string teams[], int size);
void findWinner (string teams[], int size);

int main ()

{

const int SIZE = 118;
int lastIndex;
string team[SIZE];

fill (team, SIZE);
findWinner (team, SIZE);

return 0;
}

fstream fin ("WorldSeriesWinners.txt", ios::in);

void fill (string teams[], int size){
int i;
for (i = 0; i < size; i++) {
cin >> teams[i];
}
}

void findWinner (string teams[], int size){
char c;
do {
int i, year = 1903, count = 0;
string team;
cout << "Enter team:";
cin >> team;
transform (team.begin (), team.end (), team.begin () );
for (i = 0; i < size; i++){
transform (teams[i].begin (), teams[i].end (),teams[i].begin () );
if (teams[i].compare (team) == 0);
{
cout << team << " won the World Series in " << year << endl;
count++;
}
year++;
}
if (count == 0)
cout << team << " never won a World Series" << endl;
cout << "Run another search? (y/n): ";
cin >> c;
}
while (c == 'y');
}

Enter team: Nationals
Nationals won the World Series in 2019
Run another search? (y/n): y
Enter team: Eagles
Eagles never won a World Series
Run another search? (y/n): y
Enter team: Giants
Giants won the World Series in 1905
Giants won the World Series in 1921
Giants won the World Series in 1922
Giants won the World Series in 1933
Giants won the World Series in 1954
Giants won the World Series in 2010
Giants won the World Series in 2012
Giants won the World Series in 2014
Run another search? (y/n): y
Enter team: Rangers
Rangers never won a World Series
Run another search? (y/n):
Transcribed Image Text:Enter team: Nationals Nationals won the World Series in 2019 Run another search? (y/n): y Enter team: Eagles Eagles never won a World Series Run another search? (y/n): y Enter team: Giants Giants won the World Series in 1905 Giants won the World Series in 1921 Giants won the World Series in 1922 Giants won the World Series in 1933 Giants won the World Series in 1954 Giants won the World Series in 2010 Giants won the World Series in 2012 Giants won the World Series in 2014 Run another search? (y/n): y Enter team: Rangers Rangers never won a World Series Run another search? (y/n):
110 GIANTS
80 CARDINALS
ca CARDINALS
89 TWINS
1 AMERICAS
2 NO_SERIES
45 YANKEES
2
46 INDIANS
90 BLUE JAYS
3 GIANTS
47 YANKEES
91 BLUE JAYS
4 WHITE_SOx
5 CUBS
6 CUBS
7 PIRATES
8 ATHLETCS
9 ATHLETICS
48 YANKEES
92 STRIKE_CANCELLED_SERIE
93 BRAVES
94 YANKEES
49 YANKEES
50 YANKEES
51 YANKEES
95 MARLINS
52 GAINTS
96 YANKEES
53 DODGERS
97 YANKEES
10 RED SOXX
54 YANKEES
98 YANKEES
11 ATHLETICS
55 BRAVES
99 DIAMONBACKS
12 BRAVES
56 YANKEES
100 ANGELS
13 RED SOX
57 DODGERS
101 MARLINS
102 RED SOXx
103 WHITE Sox
14 RED_SOX
58 PIRATES
15 WHITE_SOX
59 YANKEES
16 RED_SOX
60 YANKEES
104 CARDINALS
17 REDS
61 DODGERS
105 RED_SOX
18 INDIANS
62 CARDINALS
106 PHILLIES
19 GIANTS
63 DODGERS
107 YANKEES
20 GIANTS
64 ORIOLES
108 GIANTS
21 YANKEES
65 CARDINAKLS
109 CARDINALS
66 TIGERS
67. METS
22 SENATORS
110
23 PIRATES
111 RED_SOX
112 GIANTS
113 ROYALS
24 CARDINALS
68 ORIOLES
25 YANKEES
69 PIRATES
70 ATHLETICS
71 ATHLETICS
72 ATHLETICS
26 YANKEES
114 CUBS
27 ATHLETICS
115 ASTROS
28 ATHLETICS
116 RED SOXX
29 CARDINALS
73 REDS
117 NATIONALS
30 YANKEES
118 DODGERS
74 REDS
E VANKE
75 YANKEES
31 GIANTS
32 CARDINALS
76 YANKEES
33 TIGERS
77 PIRATES
19 DHILLIES
34 YANKEES
78 PHILLIES
10. DODGERS
35 YANKEES
36 YANKEES
37 YANKEES
80 CARDINALS
81 ORIOLES
82 TIGERS
83 ROYALS
38 REDS
39 YANKEES
40 CARDINALS
84 METS
41 YANKEES
85 TWINS
42 CARDINALS
86 DODGERS
43 TIGERS
87 ATHLETICS
44 CARDINALS
88 REDS
Cancel
Print
Transcribed Image Text:110 GIANTS 80 CARDINALS ca CARDINALS 89 TWINS 1 AMERICAS 2 NO_SERIES 45 YANKEES 2 46 INDIANS 90 BLUE JAYS 3 GIANTS 47 YANKEES 91 BLUE JAYS 4 WHITE_SOx 5 CUBS 6 CUBS 7 PIRATES 8 ATHLETCS 9 ATHLETICS 48 YANKEES 92 STRIKE_CANCELLED_SERIE 93 BRAVES 94 YANKEES 49 YANKEES 50 YANKEES 51 YANKEES 95 MARLINS 52 GAINTS 96 YANKEES 53 DODGERS 97 YANKEES 10 RED SOXX 54 YANKEES 98 YANKEES 11 ATHLETICS 55 BRAVES 99 DIAMONBACKS 12 BRAVES 56 YANKEES 100 ANGELS 13 RED SOX 57 DODGERS 101 MARLINS 102 RED SOXx 103 WHITE Sox 14 RED_SOX 58 PIRATES 15 WHITE_SOX 59 YANKEES 16 RED_SOX 60 YANKEES 104 CARDINALS 17 REDS 61 DODGERS 105 RED_SOX 18 INDIANS 62 CARDINALS 106 PHILLIES 19 GIANTS 63 DODGERS 107 YANKEES 20 GIANTS 64 ORIOLES 108 GIANTS 21 YANKEES 65 CARDINAKLS 109 CARDINALS 66 TIGERS 67. METS 22 SENATORS 110 23 PIRATES 111 RED_SOX 112 GIANTS 113 ROYALS 24 CARDINALS 68 ORIOLES 25 YANKEES 69 PIRATES 70 ATHLETICS 71 ATHLETICS 72 ATHLETICS 26 YANKEES 114 CUBS 27 ATHLETICS 115 ASTROS 28 ATHLETICS 116 RED SOXX 29 CARDINALS 73 REDS 117 NATIONALS 30 YANKEES 118 DODGERS 74 REDS E VANKE 75 YANKEES 31 GIANTS 32 CARDINALS 76 YANKEES 33 TIGERS 77 PIRATES 19 DHILLIES 34 YANKEES 78 PHILLIES 10. DODGERS 35 YANKEES 36 YANKEES 37 YANKEES 80 CARDINALS 81 ORIOLES 82 TIGERS 83 ROYALS 38 REDS 39 YANKEES 40 CARDINALS 84 METS 41 YANKEES 85 TWINS 42 CARDINALS 86 DODGERS 43 TIGERS 87 ATHLETICS 44 CARDINALS 88 REDS Cancel Print
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education