Phase 1 – Numbers
Prior to starting this phase, make sure you download numTestData.txt and numbers.txt from the Moodle class website. numTestData.txt will be the input file you use to get your program working. numbers.txt contains a larger data set and should be used for input only after your program works perfectly.
Write a console program (NO GUI) called NumberSorter which does the following:
1. Open and read the first line of the input file.
2. Create an integer array named numberArray with size to match the first line of the file. So if the first line of the file contains 500, the array will have 500 “slots.”
3. Read the remaining lines of the input file, parsing them as numbers, and assigning them to slots in numberArray.
4. Write a method named sort, which takes numberArray as a parameter and sorts the array from low to high.
5. Once numberArray has been sorted, use a simple loop to compute the average of the numbers in the array (not including the count).
6. When sorting is completed and the average has been calculated, open a file named dataout.txt and write the following information to it:
a. The count (number of “slots” in numberArray).
b. The sorted list of numbers in numberArray (one per line).
c. The calculated average of the numbers in the array.
Once are certain that your NumberSorter.java program works perfectly, change the name of the input file to numbers.txt and run the program. This should produce an output file containing the number 100 on the first line followed by the sorted list of numbers from 1 to 100, and then the average on the last line.
陆续还会有题目发布,这里面涵盖了数组,流的知识。关键是你还要读的懂英语哦。亲!
大家都来试试吧!!

