The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 398 Weeks Ago, 3 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
Write a java program that reads a sequence of names (first name followed by last name, separated by at least one space) from a text file and:
1) Displays the list of names (last name followed by a comma, followed by one space, followed by first name) that are read from the input file in ascending order.
2) For each first name in the file, displays the number of times that the first name appears in the file. (i.e. firstName: count). This list of first names must be displayed in the ascending order of the first names. Each first name must be capitalized (first letter in upper case and the remaining letters in lower case) and displayed only once.
3) For each last name in the file, displays the number of times that the last name appears in the file. (i.e. lastName: count). This list of last names must be displayed in the ascending order of the last names. Each last name must be capitalized (first letter in upper case and the remaining letters in lower case) and displayed only once.
4) For each name in the file, (last name followed by a comma, followed by one or more spaces, followed by first name) displays the number of times that the names appears in the file. (i.e. name: count). This list of names must be displayed in the ascending order of the names. All first and last names must be capitalized. Each name must be displayed only once. First names, last names and counts must be lined up as per the example below.
5) Displays the list of unique names (last name followed by a comma, followed by one or more spaces, followed by first name) in ascending order. First names and last names must be lined up as per the example below.
6) Displays the list of unique names (last name followed by a comma, followed by one or more spaces, followed by first name) in ascending order to a text file. First names and last names be lined up similar to display in item 5.
For example, if the input file contains:
colette Sapienza
gretta Beumer
EMManuel Mossman
Colette Sapienza
marcia Jones
Shawanda Hutt
Adriana monTILla
adriana montilla
Adriana Montilla
Colette Jones
Colette Hutt
Marcia Stanfill
NeVa shover
tijuana Means
Adriana Montilla
gerri KoeNig
Kirsten beres
Kirsten Beres
The output should be:
Enter the name of the input file
input.txt
******* All Names *********
Beres, Kirsten
Beres, Kirsten
Beumer, Gretta
Hutt, Colette
Hutt, Shawanda
Jones, Colette
Jones, Marcia
Koenig, Gerri
Means, Tijuana
Montilla, Adriana
Montilla, Adriana
Montilla, Adriana
Montilla, Adriana
Mossman, Emmanuel
Sapienza, Colette
Sapienza, Colette
Shover, Neva
Stanfill, Marcia
******* First Names count*********
Adriana 4
Colette 4
Emmanuel 1
Gerri 1
Gretta 1
Kirsten 2
Marcia 2
Neva 1
Shawanda 1
Tijuana 1
******* Last Names count *********
Beres 2
Beumer 1
Hutt 2
Jones 2
Koenig 1
Means 1
Montilla 4
Mossman 1
Sapienza 2
Shover 1
Stanfill 1
******* All Names count*********
Beres, Kirsten 2
Beumer, Gretta 1
Hutt, Colette 1
Hutt, Shawanda 1
Jones, Colette 1
Jones, Marcia 1
Koenig, Gerri 1
Means, Tijuana 1
Montilla, Adriana 4
Mossman, Emmanuel 1
Sapienza, Colette 2
Shover, Neva 1
Stanfill, Marcia 1
******* All Unique Names *********
Beres, Kirsten
Beumer, Gretta
Hutt, Colette
Hutt, Shawanda
Jones, Colette
Jones, Marcia
Koenig, Gerri
Means, Tijuana
Montilla, Adriana
Mossman, Emmanuel
Sapienza, Colette
Shover, Neva
Stanfill, Marcia
Enter the name of the output file
output.txt
Â
|
Your program must at least contain and use the following methods: public static void getNames(ArrayList fn, ArrayList ln) throws IOException |
Prompts the user for the name of an input file containing a list of first and last names as described above and reads the list of first and last names contained in the input file into ArrayLists fn and ln. You can assume that the input file format is correct. |
|
public static void capitalize( ArrayList names) |
Capitalizes all strings in names |
|
public static void display( ArrayList names) |
Displays content of the ArrayList names |
|
public static void writeToFile ( ArrayList names) throws IOException { |
Prompts the user for the name of an output file and writes the contents of the ArrayList names into the output file. |
|
public static int find (String s, ArrayList a) |
Looks for s in a. If s is found at a position j of a, returns j. Otherwise returns -1. |
|
public static void sort(ArrayList names)   CANNOT USE ArrayList's Sort Method. |
Sorts ArrayList names   |
</pstyle="font-size:>
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll