repl.it
@sdemodica/

Ch 7 Programming Challenge #16

C++

No description

fork
loading
Files
  • main.cpp
  • Teams.txt
  • WorldSeriesWinners.txt
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <iostream>
#include <string>
#include <fstream>
using namespace std;

int main()
{
  const int teamWinner = 108;

  string teamEntry;
  string winner[teamWinner];

  ifstream inputFile;
  ifstream inputFile2;

  string namesFromTeamsFile;

  int count = 0,
      total = 0;


//display teams
inputFile.open("Teams.txt");
cout << "-------------------------------\n";
  while (getline(inputFile, namesFromTeamsFile))
  {
    cout << namesFromTeamsFile << endl;
  }
cout << "-------------------------------\n";
inputFile.close();


//enter name
cout << "\nEnter a team name and that team's World Series statistics\n";
cout << "will be displayed\n\n";

getline(cin, teamEntry);



//input winning stats
inputFile2.open("WorldSeriesWinners.txt");
while(count < teamWinner && getline(inputFile2, winner[count]))
{
  count++;
}
inputFile2.close();


//This is my issue, it won't compare
for(int count2 = 0; count2 < teamWinner; count2++)
{
  if(teamEntry == winner[count2])
  {
    cout << "Test";

    total += count2;
  }
}

cout << "This team has won the world series " << total << " times.";

return 0;
}
Fetching token
?