云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > wus t java5次上机必备

wus t java5次上机必备

  • 62 次阅读
  • 3 次下载
  • 2025/12/9 7:26:27

1)实验代码 实验一: import java.util.*; public class Test { public static void main(String[] args) { int n = 10; 主 int[] array = getIntegers(new Scanner(System.in), n); 要实 Arrays.sort(array); 验 System.out.printf(\记 System.out.printf(\录 及 } 个 人 小 private static int[] getIntegers(Scanner scanner, int count) { 结 int[] array = new int[count]; while (true) { (包 System.out.printf(\括 try { 部分 for (int i = 0; i < 10; ++i) { 实验 array[i] = Integer.parseInt(scanner.next()); 源程 } 序 return array; 、调 } catch (NumberFormatException e) { 试结 System.out.println(\果 } 及实 } 验结 } 果分} 析 等)实验二: import java.io.*; public class CopyFile { public static void main ( String args[] ) { } static String deleteComments(String s) { if( null == s ) return s; String infname = \String outfname = \try { } catch(FileNotFoundException e1) { } catch(IOException e2) { } e2.printStackTrace(); System.err.println(\File fin = new File(infname); File fout = new File(outfname); BufferedReader in = new BufferedReader(new FileReader(fin)); PrintWriter out = new PrintWriter(new FileWriter(fout)); String s = in.readLine(); while( s != null ) { } in.close(); out.close(); 主要实验记录及个人小结 (包括部分实验源程序、调试结果及实验结果分析等) s = deleteComments(s); if( s.length()!=0 ) out.println(s); s = in.readLine(); int pos = s.indexOf(\if( pos < 0 ) return s; return s.substring(0, pos); } } 2)实验结果: 实验一: 主要 实 验 记 录 及 个 人 实验二: 小 结 (包括部分实验源程 序 、3)程序调试过程中存在问题的思考 调试程序调试过程中存在问题:在编译时总是出现了子类没有实现父类的方法 结果解决办法:发现把getPay误写成了getpay ,在每个子类中的getPay方法前也要加及public,不然也会出现没有实现父类的方法的提示。 实验 结果分 析等) 二、思考题 1) 程序清单 思考题一: import java.io.*; public class Stdfile { static int max(int a[], int n) //最高分 主要实验记录及个人小结(包括部分实验源程序、调试结果及实验结果分析等) { int temp = a[0]; //临时变量 for(int i = 1; i < n; i++) if(a[i] > temp) temp = a[i]; return temp; } static int min(int a[], int n) //最低分 { int temp = a[0]; for(int i = 1; i < n; i++) if(a[i] < temp) temp = a[i]; return temp; } static int average(int a[], int n) // 求平均值 { int temp = 0; for(int i = 0; i < n; i++) temp += a[i]; return temp/n; } public static void main(String args[]){ try{ File fin = new File(\ File fout = new File(\ BufferedReader in = new BufferedReader(new FileReader(fin)); //读文件Std1.txt PrintWriter out = new PrintWriter(new FileWriter(fout)); //写到Std2.txt int[] scores = new int[30]; int flag = 0; int num = 0; String s = in.readLine(); flag++; while(s != null){ if(flag%2==0){ scores[num] = Integer.valueOf(s); num++; } s = in.readLine(); flag++; } int maxValue = max(scores, 30); int minValue = min(scores, 30); int averageValue = average(scores, 30); System.out.println(\所有学生的最高分是:\

搜索更多关于: wus t java5次上机必备 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

1)实验代码 实验一: import java.util.*; public class Test { public static void main(String[] args) { int n = 10; 主 int[] array = getIntegers(new Scanner(System.in), n); 要实 Arrays.sort(array); 验 System.out.printf(\记 System.out.printf(\录 及 } 个 人 小 private static int[] getIntegers(Scanner scanner, int count) { 结 int[] array = new int[count]; while (true) { (包 System.out.printf(\

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com