
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
- Code a function to fill an empty array
- Fill an array from an input file
- Search the array for specific elements
- Output specific array elements as part of a string
- Use a for loop to step through an array
- Use a for loop to count occurrences in an array
- Use a conditional statement within a for loop used to process an array
- Use input stream objects
- 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');
}



Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images

- Create a flowchart and c code: You must use at least two different arrays - These are, in effect, parallel arrays: One for Adult Meals One for Child Meals Remember to use a "for" loop for each array You should have totals in $ amount for: Adult Meal costs For example: class1; and class2 Overall totals, combining all categories Percentage for the total categories – the % amount is your choice; for the program outcome shown below, 45% was used Hints and Suggestions: You can set your own catered meal prices – for example, adult meals are $10 You can set how many adults/children meals are sold in each category – for example, 3 adult meals sold You can also write the program to ask the user for this input, but this is not required At the end, it prints out the total dollar amount spent on sales for Adult Meals, Children Meals; and then an overall total spent. The percentage is then calculated, which is the charitable donation..arrow_forwardEXCEL VBA (a) Write a user-defined function called SumStop which takes an integer n as an input and adds up the values of the cells in row 1 (starting from cell A1) until the value of the sum exceeds n, and then outputs the number of cells used. You may assume that all of the cells in row 1 contain numbers. Use a suitable Do While loop and the cells command. Declare all variable types and include appropriate comments in your code.arrow_forwardNote: It`s C++ codingarrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





