This program must be in java, use printf, and request user inputfor a file name.
- NameSubsLast3 (30 points)
Write a program that does the following.
Write a program that does the following.
Requests the name of an input file and uses it to create aninput file Scanner.
Requests the name of an output file and uses it to create aPrintWriter.
I have posted firstNames.txt and outNames.txt in the homeworkfor Lesson 6.
Calls createArray to create a one-dimensionalString array with 100 rows, and accepts the reference to thatarray.
Reads in first names from the input file into the array createdby createArray. You may assume that the file hasno more than 100 names. Also assume that each name has at least 3characters. (Hint: use the next method). There could be more thanone name on a line.
Calls lastThree with a reference to the arraycreated in createArray, and the number of namesread in, to create a set of Strings and return a one-dimensionalString array as described below.
Prints to the output file on a separate line the String in eachrow of the array created in createArray followedby a space followed by the String created inlastThree.
createArray: (10)
Creates a one-dimensional String array with 100 rows and returnsthe reference to that array.
lastThree: (12)
Accepts the reference to the array originally created increateArray and the number of rows that were readin from the file. This array should have a length that equals thenumber of names read in from the input file.
Obtain the String with last three characters of each name.
Converts each String to upper case, and place each upper casethree character String created into a corresponding row in a newone-dimensional String array.
Returns the one-dimensional String array
Example:
If input file is:
Jonathan Jim Bernie
Shondra Nataly
Angel
Brittany Jordan Elvis Ben
The output file, line by line, would be:
Jonathan HAN
Jim JIM
Bernie NIE
Shondra DRA
Nataly ALY
Angel GEL
Brittany ANY
Jordan DAN
Elvis VIS
Ben BEN