repl.it
@sdemodica/

Ch 7 Challenge Problem #17

C++

No description

fork
loading
Files
  • main.cpp
  • BoyNames.txt
  • GirlNames.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
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
using namespace std;

int main()
{
  vector<string> findBoy(200);
  vector<string> findGirl(200);

  ifstream inputFile,
           inputFile2;

  int count = 0,
      count2 = 0,
      index = 0;

  string name;

  cout << "Enter a name\n";

  cin >> name;

  inputFile.open("BoyNames.txt");

  while (getline(inputFile, findBoy[count]))
  {
    count++;
  }

  inputFile.close();
  
  
  inputFile2.open("GirlNames.txt");

  while (getline(inputFile2, findGirl[count2]))
  {
    count2++;
  }

  inputFile2.close();


  for(string fileNames : findBoy)
  {
    if(name == fileNames)
    {
      cout << "Congratulations! Your name is on the popular boy names list.";
    }
  }


  for(string fileNames2 : findGirl)
  {
    if(name == fileNames2)
    {
      cout << "Congratulations! Your name is on the popular girl names list.";
    }
  }

  return 0;
}
Fetching token
?