‍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的更多相关文章

  1. Common Vulnerability Scoring System CVSS

    1.Generating a Shell payload using msfvenom 2.web intrusion Test in fact in the websecurity ,the web ...

  2. Scoring and Modeling—— Underwriting and Loan Approval Process

    https://www.fdic.gov/regulations/examinations/credit_card/ch8.html Types of Scoring FICO Scores    V ...

  3. Bioinformatics Glossary

    原文:http://homepages.ulb.ac.be/~dgonze/TEACHING/bioinfo_glossary.html Affine gap costs: A scoring sys ...

  4. Threat Risk Modeling Learning

    相关学习资料 http://msdn.microsoft.com/en-us/library/aa302419(d=printer).aspx http://msdn.microsoft.com/li ...

  5. Notes of Linked Data concept and application - TODO

    Motivation [反正债多了不愁,再开个方向.] Data plays a core role in most business systems, data storage and retrie ...

  6. Android开源项目SlidingMenu深切解析

    demo:http://download.csdn.net/detail/javadxz/6954819 SlidingMenu的是一种斗劲新的设置界面或设备界面结果,在主界面左滑或者右滑呈现设置界面 ...

  7. The 2014 ACM-ICPC Asia Regional Anshan Online

    [A]无向图的双联通子图计数.DP+状态压缩 [B]计算几何(点的旋转) [C]DP+状态压缩 [D]离散数学+DP (感觉可出) [E]概率DP [F]LCT模板题(-_-///LCT是啥!!!!) ...

  8. CVSS3.0打分学习

    打分计算器: Common Vulnerability Scoring System Version 3.0 Calculator: https://www.first.org/cvss/calcul ...

  9. hdu5003 Osu!排序实现水题

    Osu! is a famous music game that attracts a lot of people. In osu!, there is a performance scoring s ...

随机推荐

  1. 01-Spring概述(总览)

    Spring概述 前言 Spring 发展至现在,俨然成为一个生态,但要理解其余的 Spring Boot.Spring Cloud 等框架,需要先对 Spring 的整个体系有一定的理解,因为其余的 ...

  2. BeautifulSoup爬取微博热搜榜

    获取url 设定请求头 requests发出get请求 实例化BeautifulSoup对象 BeautifulSoup提取数据 import requests 2 from bs4 import B ...

  3. MQ 架构与细节

    MQ 架构与细节 MQ 是什么? MQ:MessageQueue,消息队列的简称,用于进程间通信或同一进程的不同线程间的通信方式. 什么时候该使用MQ? 数据驱动的任务依赖 上游不关心执行结果 上游关 ...

  4. 「Leetcode-算法_MId1006」从单栈到双栈

    Mid 1006 笨阶乘 栈/后缀 运算优化 + 栈 思路描述 每四个数一组 这四个数中前三个会进行乘.除 然后与最后一个相加 Stack 入前三个之和 与 最后一个数 以 4 举例 运算式 4 * ...

  5. ls:未找到命令

    解决,别问为什么. 执行 export PATH=/bin:/usr/bin:$PATH

  6. CodeForces CF862E题解

    \(Part\ 1:\) 我们发现每次修改动的是\(a\)串,所以对于这个答案的公式,\(b_{i+j}\)的部分是可以求出来的.所以我们可以把公式改成如下所示: \(f(j)=|\sum_{i=1} ...

  7. 启用reuse_port参数让Nginx性能提升3倍

    为什么启用 reuse_port 记得 2008 年做性能测试的时候,新进7台 lenovo 4核4G 服务器用于性能测试. 当时资源紧张,这7台服务器都装了双系统(Win2003/CentOS5)空 ...

  8. Python基础(十三):for循环

    对于一个序列,比如说:列表.字符串,有时候我们需要获取其中的每一个元素,然后执行某个操作,此时就需要借助于for循环. for循环语法结构 for循环的语法结构如下,这里大家必须清楚一点,for循环后 ...

  9. Windows安装完ADFS后卸载ADFS清除ADFS数据库

    ADFS卸载后不会卸载掉之前ADFS配置后留下来的数据库,所以如果有必要去删掉这个数据库的话需要找到对应的路径去将数据库删除掉. 具体路径为C:/windows/wid/data/adfsartifa ...

  10. JavaScript深入理解-PWA渐进式应用

    WPA-渐进式 web 应用 PWA 是什么 渐进式 Web 应用,提升 web app 浏览体验. manifest 应用程序清单 基本介绍: web app manifest是 PWA 技术集合中 ...