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 ...
随机推荐
- C语言入门--初来乍到
Hi,我是fish-studio,这是我写的第一篇博客,接下来我会以萌新的角度来与大家一起学习C语言,我也不是什么大佬,在我写的教程中会尽量详细的把我遇到的问题写出来,也会结合一些网上的文章进行编写, ...
- Codeforces Round #574 (Div. 2) E. OpenStreetMap 【单调队列】
一.题目 OpenStreetMap 二.分析 对于二维空间找区间最小值,那么一维的很多好用的都无法用了,这里可以用单调队列进行查找. 先固定一个坐标,然后进行一维的单调队列操作,维护一个区间长度为$ ...
- Django分页器组建
class Pagination(object): def __init__(self,current_page,all_count,per_page_num=2,pager_count=11): & ...
- python 序列与字典
序列概念: 序列的成员有序排列,可以通过下标访问到一个或几个元素,就类似与c语言的数组. 序列的通用的操作: 1:索引 11 = [1,2,3,4] 11[0] = 1 2:切片 11[1,2,3,4 ...
- ASPOSE.Cells & ASPOSE.Words 操纵Excel和Word文档的 .NET Core 实例
Aspose.Total是Aspose公司旗下的最全的一套office文档管理方案,它提供的原生API可以对Word.Excel.PDF.Powerpoint.Outlook.CAD.图片.3D.ZI ...
- 13、Script file 'E:\Anaconda Distribution\Anaconda\Scripts\pip-script.py' is not present.
pip-script.py文件缺失问题 问题: Script file 'E:\Anaconda Distribution\Anaconda\Scripts\pip-script.py' is not ...
- [高精度]P1096 Hanoi 双塔问题
Hanoi 双塔问题 题目描述 给定A.B.C三根足够长的细柱,在A柱上放有2n个中间有孔的圆盘,共有n个不同的尺寸,每个尺寸都有两个相同的圆盘,注意这两个圆盘是不加区分的(下图为n=3的情形). 现 ...
- 让你的程序炫起来!少有人知道但超酷的 Python 进度条开源库
本文适合有 Python 基础的朋友 本文作者:HelloGitHub-Anthony HelloGitHub 推出的<讲解开源项目>系列,本期介绍让你快速拥有完美进度条的 Python ...
- Java字节流和字符流,是时候总结一下IO流了
目录 从接收输入值说起 字节流读取 字符流读取 Scanner 读取 什么是 IO 流 字节流和字符流 字节流 字节输入流 字节输出流 缓冲流的原理 字符流 字符输入流 字符输出流 为什么字符流需要 ...
- 「starter推荐」简单高效Excel 导出工具
EasyExcel EasyExcel是一个基于Java的简单.省内存的读写Excel的开源项目.在尽可能节约内存的情况下支持读写百M的Excel. 64M内存1分钟内读取75M(46W行25列)的E ...