14章示例4
来源:互联网 发布:佛教通史知无涯 编辑:程序博客网 时间:2024/04/30 12:47
import java.util.Scanner;public class GG {/* * 求平均分 * * @param scores 参赛成绩数组 */public int qiuhe(int[] scores) {int sum = 0;for (int i = 0; i < scores.length; i++) {sum += scores[i];}return sum;}/* * 求最高分 * * @param scores参赛成绩数组 */public int calMax(int[] scores) {int max = scores[0];for (int i = 1; i < scores.length; i++) {if (max < scores[i]) {max = scores[i];}}return max;}public double pingjun(int[] scores) {int sum = 0;for (int i = 0; i < scores.length; i++) {sum += scores[i];}double avg = sum / scores.length;return avg;}public int calMin(int[] scores) {int min = scores[0];for (int i = 0; i >= scores.length; i++) {if (min < scores[i]) {min = scores[i];}}return min;}}import java.util.Scanner;public class II {public static void main(String[] args) {GG st = new GG();int[] scores = new int[5];//保存比赛成绩Scanner input = new Scanner(System.in);System.out.println("请输入五位参赛者的成绩:");for (int i = 0; i < 5; i++) {//循环接受成绩scores[i] = input.nextInt();}//输出平\平均成绩int j=st.qiuhe(scores);System.out.println("和为:"+j); double avgScore=st.pingjun(scores);System.out.println("五位参赛者的平均成绩:"+avgScore);//输出最高成绩int maxScore=st.calMax(scores);System.out.println("最高成绩"+maxScore);int minScore=st.calMin(scores);System.out.println("最小成绩:"+minScore);}}
0 0
- 14章示例4
- 14章示例3
- 14章 示例3
- 十四章示例4
- 第十四章 示例4
- 十四章示例4
- Accp 7.0 第14章 示例4 可用作参考
- APUE16章的运行示例16-14
- ACCPJAVAS1第14章示例四
- 第4章 数组上课示例
- 示例14 开发程序包
- 第二章作业示例
- 第十四章 示例5
- 十五章示例6
- 15章示例8
- 十五章示例7
- 十五章示例9
- 第十五章示例6
- 十四章上机2
- Windows7_设置VPN
- Tablayout的简单应用
- 自动布局之cell
- 理解SSL/TLS协议
- 14章示例4
- Android SharedPreferences 简单封装
- Spring Boot中使用自定义的properties
- 工银二维码支付,商户福利等你拿
- 提交应用到iTunes Connect时构建版本“正在处理”后直接消失——此构建版本无效
- 深度学习(DL)与卷积神经网络(CNN)学习笔记随笔-03-基于Python的LeNet之LR(转)
- JNI实现的视频数据转换
- Hadoop Balancer运行速度优化
- C/C++复习(7):指针