# (Solved): HOMEWORK SORT AND MERGE Write A Program That Performs The Following Tasks: Display A Friendly Greeti...

HOMEWORK

SORT AND MERGE

Write a program that performs the following tasks:

• Display a friendly greeting to the user
• Prompt the user for a file name (a list of numbers to be sorted)
• Accept that file name
• Prompt the user for a second file name (another list of numbers to be sorted)
• Accept that file name
• Open and read the data in the first file
• Sort that data using an algorithm that you wrote yourself (not Array.sort)
• The lists will be sufficiently large that a â€œsimpleâ€ algorithm wonâ€™t suffice
• Open and read the data in the second file
• Sort that data, again using your own algorithm
• Merge the two sorted lists into a single sorted file (see Problem 7-31) using a linear algorithm.
• Prompt the user for a file name
• Create that file and dump the merged list to the file, using the format specified

The file format is as follows: a single integer, followed by that number of integers. That way you can open the file, read the first value, create an array of the appropriate size, and then read the rest of the file to populate the array. For example

10

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

is data in the specified format. The first 10 is the count, not a data item; the second one is.

Note that there can be more data items than indicated by the count; ignore the extras.

Every discrete task should be implemented as an independent function. At a minimum, you will have one sorting function and one merging function.

The program should check the command line for the parameters. If three command-line parameters are given, accept them; otherwise, prompt for all three.

please write the code that can work in command line. thanks.

We have an Answer from Expert

Code: import java.io.*; import java.util.*; class prog{ static int partition(int arr[], int l, int h) { int pivot = arr[h]; int i = l-1; for (int j=l; j
We have an Answer from Expert