Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task 5 (20 pts.) File SortBylength.java given below contains an incomplete program. The goal of the program is to read a text file into an

image text in transcribed

image text in transcribed

image text in transcribed

Task 5 (20 pts.) File SortBylength.java given below contains an incomplete program. The goal of the program is to read a text file into an array list of strings, and then sort th strings appear in ascending order of their length. Complete that program, by defining a sortByLength function, that satisfies the following specs: at list, so that the Function sortByLength takes one argument, called input_list, that is an array list of strings. The function should return an array list called result with length equal to the length of A. The result should contain the same elements as A, but in ascending order of their length. IMPORTANT: You are NOT allowed to modify in any way the main function. Y auxiliary functions. ou are free to define and use Hint: my solution also includes (and uses) the insertBeforeLonger function from the previous task. My solution takes five lines of code, in addition to the insertBeforeLonger function. This is an example run of the program, using input file fmlin1.txt Please enter the name of the input file: fmlinl.txt Input: [whale, cat, elephant, donkey, goat] output: [cat, goat, whale, donkey, elephant ] This is an example run of the program, using input file fmlin2.txt Please enter the name of the input file: fmlin2.txt Input: (Massachusetts, Texas, oregon, Utah, california, New York, Florida] output: [Utah, Texas, Oregon, Florida, New York, california, Massachusetts ] SortByLength.java

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals Design

Authors: Marion Donnie Dutton Don F. Seaman

14th Edition Globel Edition

1292107634, 978-1292107639

More Books

Students also viewed these Databases questions

Question

=+What is the nature of the unions in the particular country?

Answered: 1 week ago

Question

How many Tables Will Base HCMSs typically have? Why?

Answered: 1 week ago

Question

What is the process of normalization?

Answered: 1 week ago