import java.util.Scanner;

 public class Solution
 {
     public static void main(String[] args)
     {
         Scanner input = new Scanner(System.in);

         System.out.print("Enter scores, end with negative number: ");
         double sumOfScores = 0;
         double average = 0;
         int numberOfScores = 0;
         int numberOfLarger = 0;
         int numberOfSmaller = 0;
         double[] array = new double[50];
         int i = 0;

         while(true)
         {
             array[i] = input.nextDouble();

             if(array[i] < 0)
                 break;
             sumOfScores += array[i];
             i++;
             numberOfScores++;
         }

         input.close();

         average = sumOfScores / numberOfScores;

         for(int j = 0; j <= i; j++)
         {
             if(array[j] >= average)
                 numberOfLarger++;
             else
                 numberOfSmaller++;
         }

         System.out.println("The count of higher than average is: " + numberOfLarger);
         System.out.println("The count of lower than average is: " + numberOfSmaller);
     }
 }

HW6.4的更多相关文章

  1. HW6.30

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  2. HW6.29

    public class Solution { public static void main(String[] args) { int count = 0; int[] card = new int ...

  3. HW6.28

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  4. HW6.27

    import java.util.Scanner; import java.util.Arrays; public class Solution { public static void main(S ...

  5. HW6.26

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  6. HW6.25

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  7. HW6.24

    public class Solution { public static void main(String[] args) { int count = 0; int color; int numbe ...

  8. HW6.23

    public class Solution { public static void main(String[] args) { boolean[] box = new boolean[101]; f ...

  9. HW6.22

    import java.util.Arrays; public class Solution { public static void main(String[] args) { int[][] ch ...

  10. HW6.21

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

随机推荐

  1. Kafka 之 async producer (1)

    问题 很多条消息是怎么打包在一起的? 如果消息是发给很多不同的topic的, async producer如何在按batch发送的同时区分topic的 它是如何用key来做partition的? 是如 ...

  2. android下调试unity3d应用

    原地址:http://blog.csdn.net/armoonwei/article/details/7032455 目前貌似不支持断点调试,但可以通过日志打印(logcat)来跟踪. 在androi ...

  3. jquery 请求jsp传递json数据的方法

    $(function() { $("a[name=hrefID]").click(function() { var id = $(this).attr("id" ...

  4. 1990-D. 幻方

    描述 河图,黑点白点排列奥秘数阵:洛书,纵横斜三条线上数和皆15.这是一个古老的数字游戏,将1~9填入一个九宫格,使得每行.每列.对角线上数字的和都相同(为15).在西方,满足类似规律的矩阵称之为幻方 ...

  5. Tarjan+模板

    #include<stdio.h> #include<string.h> #include<stdlib.h> #include<math.h> #in ...

  6. Why does yum return error: [Errno 256] No more mirrors to try ?

    https://access.redhat.com/solutions/203603 ISSUE yum update fails with the error : [Errno 256] No mo ...

  7. 不同VLAN之间互相通信

    前话 我们经常到机房上课,想必对机房后面那层叠的跟DVD一样的机器有印象吧,那些就是交换机. 交换机作用是什么? 我这里度娘一下: 交换机(Switch)意为"开关"是一种用于电( ...

  8. 使用intellij idea搭建MAVEN+springmvc+mybatis框架

    原文:使用intellij idea搭建MAVEN+springmvc+mybatis框架 1.首先使用idea创建一个maven项目 2.接着配置pom.xml,以下为我的配置 <projec ...

  9. Eclipse字体修改设置

    修改字体 Window -> Preferences -> General -> Appearences -> Colors and Fonts 选择java选项,看到Java ...

  10. 221. Maximal Square

    题目: Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and ...