Professional Documents
Culture Documents
Exceptions & File I/O
Exceptions & File I/O
Description
The text files boynames.txt and girlnames.txt, contains a list of the 1,000 most popular boy
and girl names in the United States for the year 2003 as compiled by the Social Security
Administration.
These are blank-delimited files where the most popular name is listed first, the second
most popular name is listed second, and so on, to the 1,000th most popular name, which is
listed last. Each line consists of the first name followed by a blank space and then the
number of registered births using that name in the year. For example the girlnames.txt file
begins with:
Emily 25494
Emma 22535
Madison 19986
This indicates that Emily was the most popular name with 25,494 registered names,
Emma was the second most popular with 22,532, and Madison was the third most
popular with 19,986.
Write a program that will read both the girls and boys files into memory using arrays. If
the files do not exist then display a message to the screen indicating the specific file name
does not exist and update file errorLog.txt by appending the file name that caused the error,
then terminate the program. The file errorLog.txt will contain the list of all the file names,
each on a separate line, that this program had problems opening them for reading. On the
other hand, id the files do exist then proceed to reading them into arrays, one for boys and
one for girls, then prompt the user to input a name . The program should search through
both arrays. If there is a match, then it should output the popularity ranking and the
number of registered names. The program should also indicate if there is no match.
The program should then prompt the user if they which to search for another name or end
the program.
Sample Input & Output, if the user enters the name “Justice”:
Al-Marri(21156) Page 1 of 2
KJO-ITD Java Programming
Sample Input & Output, if the user enters the name “Walter” followed by another entry
for the name “AUK”:
Sample Output, if the program could not find the input text files, boynames.txt
And the file errorLog.txt would contain the following line, if this is the first time you ran
the program
boynames.txt
That the program failed three times to read the input file, first failure was due to file
boysnames.txt, the second failure was due to file boysnames.txt and the third failure was due to
the file girlsnames.txt
Due Date: Submit your code on December 12th. Please make sure you test your program
to meet the requirements mentioned above and also on program style, alignment of code,
comments, have at least a comment with your name, date.
Al-Marri(21156) Page 2 of 2