SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
Walter Savitch ,julia Lobur
Chapter:
I/o Streams As An Introduction To Objects And Classes
Exercise:
Programming Projects
Question:17 | ISBN:9780321531346 | Edition: 7

Question

The text file babynames2004.txt, which is included in the source code for this book and is available online from the book’s Web site, contains a list of the 1,000 most popular boy and girl names in the United States for the year 2004 as compiled by the Social Security Administration.

This is a space-delimited file of 1,000 entries in which the rank is listed first, followed by the corresponding boy name and girl name. The most popular names are listed first and the least popular names are listed last.

For example, the file begins with

1 Jacob Emily

2 Michael Emma

3 Joshua Madison

This indicates that Jacob is the most popular boy name and Emily is the most popular girl name. Michael is the second most popular boy name and Emma is the second most popular girl name.

Write a program that allows the user to input a name. The program should then read from the file and search for a matching name among the girls and boys. If a match is found, it should output the rank of the name. The program should also indicate if there is no match.

For example, if the user enters the name "Justice," then the program should output:

Justice is ranked 406 in popularity among boys.

Justice is ranked 497 in popularity among girls.

If the user enters the name “Walter,” then the program should output:

Walter is ranked 366 in popularity among boys.

Walter is not ranked among the top 1000 girl names.

TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Sorry the answer is not available at the moment…

If you are able to find the answer, please make sure to post it here. So that your Juniors have smile on their lips and feel happy.

Spread the 'tradition of sharing'.