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 ...
随机推荐
- 数据库Redis(一)
Redis数据库的特点: Redis数据库属于nosql数据库的一种,其存储于内存中(非硬盘),修改较为方便. 而Redis数据库的存储方式是使用{key:value}方式存储,类似python基础中 ...
- MySQL入门(6)——流程控制
MySQL入门(6)--流程控制 IF语句 条件判断语句,逻辑与大多数编程语言相同,表示形式如下: IF condition THEN ... [ELSE condition THEN] ... [E ...
- python torndb模块
一.torndb概述 torndb是一个轻量级的基于MySQLdb封装的一个模块,其是tornado框架的一部分.其项目主页为:https://github.com/bdarnell/torndb . ...
- flutter资料
Flutter社区和资源传送门 新: 慕课网<Flutter入门与案例实战> | 中文网<Flutter实战>电子书 字体图标生成 http://fluttericon ...
- CSS网页的布局
1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="U ...
- gtk---实现一个登录界面
输入框 如果在GTK+中需要输入一个字符串,可以使用输入框,这是一个单行的输入构件,可以用于输入和显示正文内容. 输入框的基本操作函数 1.gtk_entry_new(void); 这是新建一个输入框 ...
- IPFS挖矿硬盘满了会怎样?
IPFS是一个互联网协议,对标现在的HTTP.所以,可以想见未来IPFS有多大的价值.所谓IPFS挖矿,是基于IPFS,挖的是filecoin,称其为filecoin挖矿倒是更为贴切.许多初接触IPF ...
- P1200_你的飞碟在这儿(JAVA语言)
题目描述 众所周知,在每一个彗星后都有一只UFO.这些UFO时常来收集地球上的忠诚支持者. 不幸的是,他们的飞碟每次出行都只能带上一组支持者.因此,他们要用一种聪明的方案让这些小组提前知道谁会被彗星带 ...
- (数据科学学习手札114)Python+Dash快速web应用开发——上传下载篇
本文示例代码已上传至我的Github仓库https://github.com/CNFeffery/DataScienceStudyNotes 1 简介 这是我的系列教程Python+Dash快速web ...
- Github Actions 还能做这些事
前言 最近公司内部项目的发布流程接入了 GitHub Actions,整个体验过程还是比较美好的:本文主要目的是对于没有还接触过 GitHub Actions的新手,能够利用它快速构建自动测试及打包推 ...