You will write a menu-driven Java application to do the activities shown in the attached example output. All of the activities involve reading the file, names.txt, which gives boys and girls names and their popularity rankings for 11 decades beginning in 1900. A popularity of 0 indicates a ranking that was 1000 or more. There are three menu items the user may choose:
Another menu choice should offer the user the opportunity to quit the application. NOTE: Always aim to make your output look like the example output.
The user should NOT be able to crash the program by entering data. Examples: entering a letter when the program expects a number, entering a decade that does not exist, entering a name that is not in the file, entering a rank that is less than 1 or more than 999 None of these or any other erroneous inputs should be capable of crashing your application: your application must defend against user attempts to crash the application.
You must force the user to enter names that ARE in the file for menu item #2. Ignore the case of user input.
Always process the file one entire line at a time, i.e., read the file using nextLine() only. You must use of the Scanner class to tokenize strings containing lines from the file.
You will be expected to organize the code using static methods to reduce redundancy and complexity. This implies that you will have separate methods for such tasks as 1) getting string data from the user, 2) getting integer data from the user, 3) getting the data from the file, 4) validating user input, 5) searching the file for a name, and any other separate tasks that you might identify. Any tasks that are repeated should be organized as a separate static method, and then called by whatever section of code needs to use that task. No recursion may be used, either directly (A calls itself) or indirectly (A calls B calls A). Each method should have one return and System.exit must not be used.
Use class constants wisely. Examples: starting year of the files data (1900), max or min rank, values used in creating histograms or other data.
Every method should have a prolog comment that makes very clear what the task of the method is. Be sure the main prolog COMPLETELY and CLEARLY summarizes all the functionality of this application. Finally, use inline comments to make your code simple to read and understand. Again, make your execution resemble the example output as closely as possible.
This program allows you to search through the data from the Social Security Administration name popularity since 1900.
Choose a task number from the following:
1 - See histogram of a name's popularity
2 - Compare two names in a specific decade
3 - Show what name had a specific rank for a certain decade
4 - Exit program
Enter a number, 1.. 4: 1
What name: chuCk
Name: Chuck
0-
0-
0-
846-***********
441-****************************************
378-*********************************************
306-**************************************************
635-***************************
0-
0-
0-
Choose a task number from the following:
1 - See histogram of a name's popularity
2 - Compare two names in a specific decade
3 - Show what name had a specific rank for a certain decade
4 - Exit program
Enter a number, 1.. 4: 2
First name: sAm
Second name: jiM
Choose your decade:
1 - 1900-1909
2 - 1910-1911
3 - 1920-1929
4 - 1930-1939
5 - 1940-1949
6 - 1950-1959
7 - 1960-1969
8 - 1970-1979
9 - 1980-1989
10 - 1990-1999
11 - 2000-
Enter a number, 1..11: 9
Comparing sam and jim from 1980 to 1990:
Sam: 467-***************************************
Jim: 538-*********************************
Choose a task number from the following:
1 - See histogram of a name's popularity
2 - Compare two names in a specific decade
3 - Show what name had a specific rank for a certain decade
4 - Exit program
Enter a number, 1.. 4: 3
What rank of popularity? 8
Choose your decade:
1 - 1900-1909
2 - 1910-1911
3 - 1920-1929
4 - 1930-1939
5 - 1940-1949
6 - 1950-1959
7 - 1960-1969
8 - 1970-1979
9 - 1980-1989
10 - 1990-1999
11 - 2000-
Enter a number, 1..11: 6
From 1950 to 1960 the names with popularity rank 8 were:
Karen and Thomas
Choose a task number from the following:
1 - See histogram of a name's popularity
2 - Compare two names in a specific decade
3 - Show what name had a specific rank for a certain decade
4 - Exit program
Enter a number, 1.. 4: 1
What name: karen
Name: Karen
929-******
0-
0-
141-**************************************************************
15-***********************************************************************
8-***********************************************************************
3-************************************************************************
24-**********************************************************************
80-******************************************************************
128-***************************************************************
155-*************************************************************
Choose a task number from the following:
1 - See histogram of a name's popularity
2 - Compare two names in a specific decade
3 - Show what name had a specific rank for a certain decade
4 - Exit program
Enter a number, 1.. 4: 4
Press any key to continue . . .