Question
Can you give me this program working in C++ please
95% oo H20 LTE 9:01 PM ehacc hacc.edu HACC-Harrisburg Area Community Fahringer College CPS 161 Computer Science Program #7 20 points Program Due: Monday, March 21st Word Series Task: Write a program that displays the contents of the Teams txt file on the screen and prompts the user to enter the name of one of the teams. The program should then display the number of times that team has won the World Series in the time period from 19o3 to 2012. Input: The name of one of the teams displayed from the Teams txt file. Processing: Read the contents of the World Series Winners tykt file into a vector. When the user enters the name of a team, the program should step through the vector counting the number of times the selected team appears. Output: The number of times the team entered as input has won the world series and the year(s) that they won. Teams txt-This file contains a list of several major league baseball teams in alphabetical order. Each team listed in the file has won the World Series at least once. World SeriesWinners.txt This file contains a chronological list of the World Series winning teams from 19o3 to 2012. (The first line in the file is the name of the team that won in 19o3, and the last line is the name of the team that won in 2012. Note that the World Series was not played in 19o4 and 1994)
media%2F2b8%2F2b87711f-d9c2-4e1c-b559-35
media%2F25f%2F25f40210-d9ca-47a3-ae03-a0
0 0
Add a comment Improve this question Transcribed image text
Answer #1

// C++ code
#include <iostream>
#include <string.h>
#include <vector>
#include <fstream>
using namespace std;
int main()
{
vector<string> winnerTeam;
string teamName="",line,line2;
int i=0,j=0,count=0;
ifstream inFile;
ifstream inFile2;
inFile.open("teams.txt");
inFile2.open("WorldSeriesWinner.txt");
cout<<"\n------------------------------------------------------------";
cout<<"\n----------------------- TEAM NAME LIST ---------------------";
cout<<"\n------------------------------------------------------------\n";
while (getline(inFile,line))
{
cout<<i+1<<". "<<line<<"\t\t";
i++;
if(i%2==0)
cout<<endl;
}
while (getline(inFile2,line2))
{
winnerTeam.push_back(line2);
}
cout<<"\n----------------------\n";
cout<<"\nEnter Name of Team : ";
std::getline (std::cin,teamName);
cout<<"\n----------------------\n";
for(j=0;j<winnerTeam.size();j++)
{
string temp=winnerTeam[j];
if(temp==teamName)
{
count++;
}
}
cout<<"\n\nWin Count for "<<teamName<<" : "<<count;
cout<<endl;
inFile2.close();
inFile.close();
return 0;
}


/*
output:

------------------------------------------------------------
----------------------- TEAM NAME LIST ---------------------
------------------------------------------------------------
1. Anaheim Angels       2. Arizona Diamondbacks      
3. Atlanta Braves       4. Baltimore Orioles      
5. Boston Americans       6. Boston Braves      
7. Boston Red Sox       8. Brooklyn Dodgers      
9. Chicago Cubs       10. Chicago White Sox      
11. Cincinnati Reds       12. Cleveland Indians      
13. Detroit Tigers       14. Florida Marlins      
15. Kansas City Royals       16. Los Angeles Dodgers      
17. Milwaukee Braves       18. Minnesota Twins      
19. New York Giants       20. New York Mets      
21. New York Yankees       22. Oakland Athletics      
23. Philadelphia Athletics       24. Philadelphia Phillies      
25. Pittsburgh Pirates       26. San Francisco Giants      
27. St. Louis Cardinals       28. Toronto Blue Jays      
29. Washington Senators      
----------------------

Enter Name of Team : Los Angeles Dodgers

----------------------


Win Count for Los Angeles Dodgers : 5


*/


(0:29. 71%) 10:46 PM tubuntu ubuntu@ayushv: ~/codes ubuntueayushv: I[Aubuntu ayushv:-/codess./a.out 4) g++ team.cpp 1. Anahe

Add a comment
Know the answer?
Add Answer to:
Can you give me this program working in C++ please 95% oo H20 LTE 9:01 PM...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Chapter 7, Problem 5PP in Starting out with Visual C# (4th Edition) World Series Champions Teams.txt...

    Chapter 7, Problem 5PP in Starting out with Visual C# (4th Edition) World Series Champions Teams.txt - This ile contains a list of several Major League baseball teams in alphabetical order. Each team listed in the file has one the World Series at least once. WorldSeriesWinners.txt - This file contains a chronological list of the World Series' winning teams from 1903 through 2012. Create an application that displays the contents of the Teams.txt file in a ListBox control. When the...

  • Write a java netbeans program. Project Two, Super Bowl A text file named “SuperBowlWinners.txt” contains the...

    Write a java netbeans program. Project Two, Super Bowl A text file named “SuperBowlWinners.txt” contains the names of the teams that won the Super Bowl from 1967 through 2019. Write a program that repeatedly allows a user to enter a team name and then displays the number of times and the years in which that team won the Super Bowl. If the team entered by the user has never won the Super Bowl, report that to the user instead. For...

  • ****PLEASE CODE IN C++ and line doc explaining what is happening!***** **HERE IS THE INPUT FILE(.txt)*****...

    ****PLEASE CODE IN C++ and line doc explaining what is happening!***** **HERE IS THE INPUT FILE(.txt)***** Ottawa Senators New York Rangers Boston Bruins Montreal Canadiens Montreal Canadiens Toronto Maple Leafs New York Rangers Chicago Blackhawks Montreal Maroons Detroit Red Wings Detroit Red Wings Chicago Blackhawks Boston Bruins New York Rangers Boston Bruins Toronto Maple Leafs Detroit Red Wings Montreal Canadiens Toronto Maple Leafs Montreal Canadiens Toronto Maple Leafs Toronto Maple Leafs Toronto Maple Leafs Detroit Red Wings Toronto Maple Leafs...

  • Please answer Question 4 WITH A C# PROGRAM!!!!!! THANK YOU! File Edit View History Bookmarks Tools...

    Please answer Question 4 WITH A C# PROGRAM!!!!!! THANK YOU! File Edit View History Bookmarks Tools Help Share GEP IIIA Moorhead, MN 10-Day Weathe X N NDSU Faculty and Staff | North x D C#.NET - CSCI 213: Modern Sol X VitalSource Bookshelf: Starting x + + → OO - https://bookshelf.vitalsource.com/#/books/9780134400433/cf1/6 90% *** * Cambie Meble alle... S N 10 Crosby Derek Lam ... Alterna Caviar Anti-Ag... U C# Tutorial For Beginn... BE Celsius Fahrenheit con... Charter Club Sweater. Folklorama...

  • PYTHON Text file Seriesworld attached below and it is a list of teams that won from...

    PYTHON Text file Seriesworld attached below and it is a list of teams that won from 1903-2018. First time mentioned won in 1903 and last team mentioned won in 2018. World series wasn’t played in 1904 and 1994 and the file has entries that shows it. Write a python program which will read this file and create 2 dictionaries. The first key of the dictionary should show name of the teams and each keys value that is associated is the...

  • in C PROGRAM but the techniques required are common for many real-world data situations. Input Data...

    in C PROGRAM but the techniques required are common for many real-world data situations. Input Data The following data is available in the file WHLdata-txt attached to the assignment on connex. You can open the file in a text editor and then copy and paste the data into the console window when testing your program. This data was captured on Feb. 4. We will test your program using up to date data. There are 22 teams and that will be...

  • Hello, can you please show me how to do this program with COMPLETE INPUT VALIDATION so...

    Hello, can you please show me how to do this program with COMPLETE INPUT VALIDATION so the computer tells the user to enter ints only if the user enters in floating point numbers or other characters? Write a method called evenNumbers that accepts a Scanner reading input from a file containing a series of integers, and report various statistics about the integers to the console. Report the total number of numbers, the sum of the numbers, the count of even...

  • Using c++ Write a function named coinToss that simulates tossing a coin. When you call the...

    Using c++ Write a function named coinToss that simulates tossing a coin. When you call the function it should generate and return a random number in the range 1 through 2. 1 represents heads and 2 represents tails. Exercise 1 (40 points) Write a function named coinToss that simulates tossing a coin. When you call the function it should generate and return a random number in the range 1 through 2.1 represents heads and 2 represents tails Use the function...

  • For this project, you are tasked with creating a text-based, basic String processing program that performs...

    For this project, you are tasked with creating a text-based, basic String processing program that performs basic search on a block of text inputted into your program from an external .txt file. After greeting your end user for a program description, your program should prompt the end user to enter a .txt input filename from which to read the block of text to analyze. Then, prompt the end user for a search String. Next, prompt the end user for the...

  • In c++ programming, can you please edit this program to meet these requirements: The program that...

    In c++ programming, can you please edit this program to meet these requirements: The program that needs editing: #include <iostream> #include <fstream> #include <iomanip> using namespace std; int cal_avg(char* filenumbers, int n){ int a = 0; int number[100]; ifstream filein(filenumbers); if (!filein) { cout << "Please enter a a correct file to read in the numbers from"; }    while (!filein.eof()) { filein >> number[a]; a++; } int total = number[0]; for (a = 0; a < n; a++) {...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT