Question
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
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 wont 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.
"Advance java"
please write the code that can work in command line. thanks.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started