进来试试你的J2SE基础和英语水平

william_yao 2012-11-03 05:10:29
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.

陆续还会有题目发布,这里面涵盖了数组,流的知识。关键是你还要读的懂英语哦。亲!
大家都来试试吧!!

...全文
314 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
william_yao 2012-11-04
  • 打赏
  • 举报
回复
引用 8 楼 Inhibitory 的回复:
这个题的关键在这里:numbers.txt contains a larger data set 而numTestData.txt中的数据很有限 这个问题并不像看上去那么简单,因为大多数人在用测试数据去写程序的时候相信都会使用内排序, 而实际数据非常大,如有几百M,几G的数据,这也是这个题没有限制的地方,用内排序不能解决问题,需要使用外排序, 问题就在于外排序,很多人都不会。
大牛就是大牛。 哈哈。~
william_yao 2012-11-04
  • 打赏
  • 举报
回复
引用 9 楼 zhang5059 的回复:
英语对高开发的来说真的很重要吗?上次去面试一家公司(公司名就不说了),那面试官上来就问英语过四级了吗?我说没,他非常肯定的说了句“我头一次听说搞开发的英语没过四级、、、” 没锅四级的娃该肿么办?
我觉得,进大公司,英语真的蛮重要。而且也是交流的基础。
书断华 2012-11-04
  • 打赏
  • 举报
回复
英语对高开发的来说真的很重要吗?上次去面试一家公司(公司名就不说了),那面试官上来就问英语过四级了吗?我说没,他非常肯定的说了句“我头一次听说搞开发的英语没过四级、、、” 没锅四级的娃该肿么办?
Inhibitory 2012-11-04
  • 打赏
  • 举报
回复
这个题的关键在这里:numbers.txt contains a larger data set 而numTestData.txt中的数据很有限 这个问题并不像看上去那么简单,因为大多数人在用测试数据去写程序的时候相信都会使用内排序, 而实际数据非常大,如有几百M,几G的数据,这也是这个题没有限制的地方,用内排序不能解决问题,需要使用外排序, 问题就在于外排序,很多人都不会。
wwwcomcn123 2012-11-03
  • 打赏
  • 举报
回复
如果是我 直接不做 非做不可的话 谷歌翻译 英语真心不会
anssherry 2012-11-03
  • 打赏
  • 举报
回复
黄小非 翻译的没有问题 ,作者是想要我们帮他翻译英文吧。这个数据也没有。是最基本的数据读入和数据导出计算平均值。难度不大。
aaaabbbccd9876 2012-11-03
  • 打赏
  • 举报
回复
wapigzhu 2012-11-03
  • 打赏
  • 举报
回复
这个是高中或者大学生的作业吧?
zhao0829wang2 2012-11-03
  • 打赏
  • 举报
回复
huangxiaofei 2012-11-03
  • 打赏
  • 举报
回复
首先,搞成中文,这个不应该成为编程的障碍 阶段1——数字 在开始第一阶段之前,去报你已经从Moodle class站点下载了numTestData.txt和numbers.txt这两个文件。numTestData.txt将作为你调试程序时的输入文件。numbers.txt文件是正式的数据文件,包含了大量的数据,当你的程序调试完全成功后再使用这个文件。 编写一个基于命令行的程序(不是GUI程序),该程序的名字叫做:NumberSorter,程序需要满足下列的要求: 1. 打开并读入输入文件的第一行 2. 创建一个整形数组,命名为numberArray,其大小与输入文件的第一行包含的数字相当。如果文件的第一行是500,那么数组的的大小就是500. 3. 读入输入文件余下的行,并将其转换为数字类型,然后存入到数组中对应的位置。 4. 创建一个方法,叫做sort. 这个方法以numberArray为参数,并能够将数组中的数字从小到大排序。 5. 一旦numberArray排序完成,使用简单的循环语句计算数组中所有数字所对应的平均值(不包括个数) 6. 当排序完成,平均数计算也完成,打开一个叫做dataout.txt的文件,将下列信息写入到该文件: a. 个数(也就是numberArray数组的大小) b. 排序后的numberArray中的数字序列(每行一个数) c. 计算出来的数组中所有数字的平均值 当你的NumberSorter.java程序能够正常运行以后,将输入文件名字改为numbers.txt, 并运行程序,程序运行的正常结果应该产生一个输出文件,该文件的第一行应该是数字100,其后是经过排序的数字,从1到100,最后一行应该是这些数字的平均值。 其次,这个没什么困难的,最基本的文件读取和数组排序
EvenFu 2012-11-03
  • 打赏
  • 举报
回复

62,621

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧