Question: This lab assignment is a continuation of the class exercise that we did using the files of baby names from the social security administration. Unlike

This lab assignment is a continuation of the class exercise that we did using the files of baby names from the social security administration. Unlike other labs, your program must use a function. The function prototype is:
int getRank(char userName[], char file[], int gender);
where userName is a name entered by the user, file is the name of the file being searched, and gender is a 1 if the list of boy baby names (first name on a row) is being searched or a 2 if the list of girl baby names (second name on a row) is being searched. Be sure to validate the number being entered for the gender. It must be a 1 or 2. The function returns the rank if found, but returns 0 if the name isn't found in the file.
Your program should ask the user for the name to be searched and the gender of the baby (which list should be searched). Then it should search the following files:
PopularNames1900s.txt
PopularNames1950s.txt
PopularNames1990s.txt
PopularNames2000s.txt
The results should be printed in a table format where the name is first, then it has Year and Rank with a line (consisting of equal signs) beneath. Below those headings it should print the year and the rank of the user's name. If the name isn't found it should print "Not ranked in top 200".
Here's a sample execution.
Enter your name: Clarence Enter 1 to search boys names or 2 to search girls names: 3 ERROR: You must enter a 1 or a 2. Please re-enter: 1 Clarence: Year Rank =========================19001719501161990 Not ranked in top 2002000 Not ranked in top 200
Please note that the names of the files start with a capital letter. When I uploaded them into Zybooks, they were all automatically capitalized. There doesn't appear to be a way to change the names so that they start with a lower case letter as they were in the class example.
Test 1 checks that you're getting information from the user and printing the correct headings. It's worth 20 points.
Test 2 checks that you're reading information from the file and finding the correct ranks for the name Clarence. It's worth 20 points.
Test 3 checks that you're validating the integer entered for the gender, as well as getting the correct ranks. It's worth 20 points.
Test 4 checks that you're able to work with girls names and get their correct ranks. It's worth 20 points.
Test 5 makes sure that you are using the correct function. Remember that it must return the rank as an integer. You will need to use the atoi() function that we discussed in the last chapter when we covered strings. This test is also worth 20 points.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!