Hi everyone. I need help on my homework assignment.
Here are the requirements
Create an application that searches a file of male and female first names. A link to the file is provided on the class webpage. "FirstNames2015.txt" is a list of the most popular baby names in the United States and was provided by the Social Security Administration. Each line in the file contains a boy's name and a girl's name. The file is space-delimited, meaning that the space character is used to separate the boy name from the girl name. The file begins with:
Noah Emma
Liam Olivia
Mason Sophia
Jacob Ava
William Isabella
Ethan Mia
James Abigail
Write a program that asks the user to enter a name. The program then searches the file for the name and displays the position of the name in the file if it matches either a boy name or a girl name. The program also displays a message if the name could not be found. Sample outputs:
Enter a name to search: Daniel
Daniel is ranked 12 for boy names
Daniel was not found for girls
[code]
// THE PROBLEM WITH MY PROGRAM IS THAT EVERYTIME I RUN IT AND ENTER A NAME THAT IS ON THE LIST, IT SAYS THAT IT IS NOT RANKED FOR BOY OR GIRLS NAME
int main()
{
string inputName, boyName, girlName;
ifstream babyFile;
int rank;
int boysRank = 0;
int girlsRank = 0;
char another = 'y';
while (another == 'y')
{
babyFile.open("FirstNames.txt");
// verify that it opened
if (babyFile.fail())
{
cout << "Can't open babyFile.txt\n";
exit(1);
}
cout << "Enter the name to search for: ";
cin >> inputName;