CPSC 220
Fall 2006
HW 5: Sorting Code
Work with your partner(s) to write a Java program to implement your sort.
You and your partner may refer to the code in L&C
and use any of your own old code. You may not, however,
directly use
significant portions of anyone else's code. Your program
should have the following behaviors:
- If your program is
called MySort, its usage should be java MySort infile outfile,
where:
- infile contains the integer data to be sorted. You should
assume that the first line of infile contains an integer that indicates
how many data items are in the file. The data then
appears one item per line with an end-of-line character
between the last data item and the EOF character. For example, if the EOF
character were visible a valid data file might look like this:
4
2
9
1
3456
EOF
- The program writes the sorted integer data to outfile,
one item per line.
If the format of the data file is invalid or the program cannot open
either the input or output file, it should terminate and print an appropriate
message.
- If your program runs successfully it should print just two things:
- The number of items sorted.
- The time required for the
sort in milliseconds. (Remember that method System.currentTimeMillis() gives
the current system time in milliseconds). IMPORTANT: This time must not include any input or output.
Your program should be self-contained, that is, it should not rely on
any other classes that are not in the standard Java library. E-mail
your source code to me before class.