Scoring System
Build a scoring system , give the score by referee , and entering the score in system , then take out the max score and the min score , print the final score in the window .
做了一个打分系统,用户输入获得的分数,然后去掉一个最高分,去掉一个最低分,然后打印输出最终得分。
️练习数组的使用,定义数组,遍历数组,以及求数组的最值操作。
️练习定义方法和调用方法。
代码如下:
import java.util.Arrays;
import java.util.Scanner;
public class score {
public static void main(String[] args) {
//定义数组,长度为7
int[] arr = new int[7];
//用户输入分数,并写进数组内
Scanner in = new Scanner(System.in);
for (int i = 0; i < arr.length; i++) {
System.out.println("请输入第" + (i + 1) + "个裁判的分数");
arr[i] = in.nextInt();
}
//通过Arrays.stream().获取值
int min = Arrays.stream(arr).min().getAsInt();
int max = Arrays.stream(arr).max().getAsInt();
int sum = Arrays.stream(arr).sum();
System.out.println(max);
System.out.println(min);
System.out.println(sum);
//通过定义的方法获取最值
System.out.println("getMax" + getMax(arr));
System.out.println("getMin" + getMin(arr));
//计算最终得分
int score = (sum-min-max)/(arr.length-2);
System.out.println("你的最终得分是:"+score+"分!!!");
}
//定义getMax的方法(返回值int,参数Arrays)(成员函数)
public static int getMax(int[] arr) {
int num = arr[0];
for (int i = 0; i < arr.length; i++) {
if (num < arr[i]) {
num = arr[i];
}
}
return num;
}
//定义getMax的方法(返回值int,参数Arrays)(成员函数)
public static int getMin(int[] arr) {
int num = arr[0];
for (int i = 0; i < arr.length; i++) {
if (num > arr[i]) {
num = arr[i];
}
}
return num;
}
}
Scoring System的更多相关文章
- Common Vulnerability Scoring System CVSS
1.Generating a Shell payload using msfvenom 2.web intrusion Test in fact in the websecurity ,the web ...
- Scoring and Modeling—— Underwriting and Loan Approval Process
https://www.fdic.gov/regulations/examinations/credit_card/ch8.html Types of Scoring FICO Scores V ...
- Bioinformatics Glossary
原文:http://homepages.ulb.ac.be/~dgonze/TEACHING/bioinfo_glossary.html Affine gap costs: A scoring sys ...
- Threat Risk Modeling Learning
相关学习资料 http://msdn.microsoft.com/en-us/library/aa302419(d=printer).aspx http://msdn.microsoft.com/li ...
- Notes of Linked Data concept and application - TODO
Motivation [反正债多了不愁,再开个方向.] Data plays a core role in most business systems, data storage and retrie ...
- Android开源项目SlidingMenu深切解析
demo:http://download.csdn.net/detail/javadxz/6954819 SlidingMenu的是一种斗劲新的设置界面或设备界面结果,在主界面左滑或者右滑呈现设置界面 ...
- The 2014 ACM-ICPC Asia Regional Anshan Online
[A]无向图的双联通子图计数.DP+状态压缩 [B]计算几何(点的旋转) [C]DP+状态压缩 [D]离散数学+DP (感觉可出) [E]概率DP [F]LCT模板题(-_-///LCT是啥!!!!) ...
- CVSS3.0打分学习
打分计算器: Common Vulnerability Scoring System Version 3.0 Calculator: https://www.first.org/cvss/calcul ...
- hdu5003 Osu!排序实现水题
Osu! is a famous music game that attracts a lot of people. In osu!, there is a performance scoring s ...
随机推荐
- android分析之消息处理
前序:每个APP对应一个进程,该进程内有一个ActivityThread的线程,称为主线程(即UI主线程),此外,还有其他线程,这个再论. android的消息系统分析. 每个Thread只对应一个L ...
- golang 实现距离幂算法
func main() { var test []Pow var x1 Pow x1.distance = 110 x1.grade = 0.31 var x2 Pow x2.distance = 8 ...
- React实用技巧
取消请求 React 中当前正在发出请求的组件从页面上卸载了,理想情况下这个请求也应该取消掉,那么如何把请求的取消和页面的卸载关联在一起呢? 这里要考虑利用 useEffect 传入函数的返回值: u ...
- Vue3手册译稿 - 深入组件 - 自定义事件
本章节需要掌握组件基础 emit我译成发射,觉得发射这个词比较形象的形容将子组件事件发射出来的一个动作. 事件名 像组件和props,事件名也会进行自动转换,如果你在子组件里发射一个驼峰命名的事件,你 ...
- 一种3位sar adc仿真验证
3位sar adc采用下图的电容阵列,电路如下图:所有电容的正端(也称为上极板)与比较器的同相端连接,比较器反相端接gnd,其工作过程进行大致分析见之前的文章<一种3位sar adc工作过程推导 ...
- 【LiteOS】Liteos移植篇
目录 前言 链接 参考 笔录草稿 移植(2018) 移植获取 (Cortex-M 内核) 主要文件夹分析 移植过程 1. 拷贝文件 2. 创建工程分组 3. 添加头文件路径 4. 兼容 C99 模式 ...
- java例题_13 加上100再加上168的完全平方数问题
1 /*13 [程序 13 根据条件求数字] 2 题目:一个整数,它加上 100 后是一个完全平方数,再加上 268 又是一个完全平方数,请问该数是多少? 3 程序分析:在 10万以内判断,先将该数加 ...
- 【linux】驱动-8-一文解决设备树
目录 前言 8. Linux设备树 8.1 设备树简介 8.2 设备树框架 8.2.1 设备树格式 8.2.1.1 DTS 文件布局 8.2.1.2 node 格式 8.2.1.3 propertie ...
- 如何快速在odoo中创建自己的菜单
上一篇内容:如何快速创建odoo模块,使用脚手架快速创建自己的odoo应用app 前言 在上一个教程中,我们已经实现了对模块的创建,现在我们要对创建的模块添加内容,这个教程将教你如何在odoo菜单中创 ...
- Autofac 框架初识与应用
文字首发地址 一.前言 这上一篇中,主要讲述了什么是IoC容器,以及了解到它是DI构造函注入的框架,它管理着依赖项的生命周期以及映射关系,同时也介绍实践了在ASP.Net Core中,默认提供的内置I ...