Homework Ch.7 – Name Search C++ Language Programming 30 points Use the links bel
ID: 3730136 • Letter: H
Question
Homework Ch.7 – Name Search C++ Language Programming
30 points
Use the links below to download the following files;•
GirlsNames.txt—This file contains a list of the 200 most popular names given to girls born in the United States from 2000 to 2009.•
BoysNames.txt—This file contains a list of the 200 most popular names given to boys born in the United States from 2000 to 2009.
Write a program that reads the contents of the two files
into two separate arrays or vectors
. The user should be able to enter a baby’s name, and the application should display
whether it is among the most popular names, and if so, whether it is a girl’s name, boy’s name or both
how would you write this program? Is this asking you to display all the names with the array, or just look up the names in the txt files?
Explanation / Answer
As mentioned in the Question there are two text files "GirlsNames.txt" and "BoysNames.txt" and each of them contains 200 most popular names given to girls/boys in the United States from 2000 to 2009
So here we got 200 girls name in GirlsNames.txt
and 200 boys name in BoysNames.txt
Now the first part of the question is to read and store the names in the text files into an array or vertors.
Since arrays are quite simplified compared to vectors, you shoud store the names into an array.
Here you will need to make 2 arrays, 1 for boys and 1 for girls of about size 200.
Then you will need to read the contents of the text files into the respective arrays.
Second Part
When the use enters a baby's name, the application should
1) Display whether it is among the most popular names.
This could be done by comparing the strings entered by the user to the contents of both the arrays (using for loop)
Now if it matches with any of the array element among the two arrays, it should print that "its among the popular names"
2) if so, whether it is a girl’s name, boy’s name or both.
if it matches with any of the array element among the two arrays then if should diplay whether it matched with the girlsnames array or boysnames array or both.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.