Question: Task 4 (15 pts.) The program task4.java given below is an incomplete program. The goal of the program is to: 1. Ask the user to

 Task 4 (15 pts.) The program task4.java given below is anincomplete program. The goal of the program is to: 1. Ask theuser to enter the name of an input text file. 2. Createan array list called input_list, containing as items the lines of theinput text file. 3. Create an empty array list of strings, called

Task 4 (15 pts.) The program task4.java given below is an incomplete program. The goal of the program is to: 1. Ask the user to enter the name of an input text file. 2. Create an array list called input_list, containing as items the lines of the input text file. 3. Create an empty array list of strings, called output_list 4. Insert into that array list the items of input list, one by one. Insertions should be done in such a way that, after each insertion, the strings in the array list are sorted in ascending order of their length. In other words, shorter strings should appear before longer strings Complete that program, by defining an insert_before_longer function, that satisfies the following specs: Function insert before_longer takes two arguments, called A, x. Argument A is an array list of strings, and argument x is a string before that element. x should be inserted at position 2, right before element "elephant". After the insertion, A should The function should look for the first element of A that is longer in length than x, and insert x right For example, if A contains elements "cat", "whale", "elephant", in that order, and x "donkey", then contain elements "cat", "whale", "donkey", "elephant", in that order

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!