This program must be in java, use printf, and request user input for a file name. NameSubsLast3...

70.2K

Verified Solution

Question

Programming

This program must be in java, use printf, and request user inputfor a file name.

  1. 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

Answer & Explanation Solved by verified expert
4.0 Ratings (466 Votes)
Thanks for the questionHere is the completed code for this problemComments are included go through it learn how things workand let me know if you have any doubts or if you need anything tochange If you are satisfied with the solutionplease rate the answer Thanksimport javaioimport javautilScannerpublic class NameSubsLast3 public static void mainString args Requests the name    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students