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. DevSecOps 实施篇!系列(二)

    想在自己公司建立 DevSecOps 计划?没问题,企业规模无论大小,都可轻松实现.这里有5个基本的 DevSecOps 原则可以帮助你启动.当然,如果你对 DevSecOps 还不太熟悉,不妨先看看 ...

  2. QT小技巧(书上没有的)

    1. Layout本身不能控制隐藏和显示,但是可以在外面专门套一个Widget,然后控制这个Widget就可以达到相应的效果了. 2. 空目录居然也存在 if (QDir(""). ...

  3. 186. Reverse Words in a String II

    题目: Given an input string, reverse the string word by word. A word is defined as a sequence of non-s ...

  4. 《RabbitMQ in action》

    Producers create messages and publish (send) them to a broker server (RabbitMQ).What’s a message? A ...

  5. 远程唤醒 N54L

    远程唤醒 N54L 我的N54L装了一块买时带的WD500G黑盘,又装了一个WD2T绿盘,存些电影歌曲什么的,当NAS用,装的WIN7系统,长时间不使用就自动关机了,每次都得按一下电源开关键,于是就研 ...

  6. C 可变参数(C与指针实例)

    偶尔我们需要设计一些函数,它们的参数数目不是固定的,这样我们需要用到可变参数列表. 可变参数列表是通过宏来实现的,定义于stdarg.h头文件. 具体内容在<C与指针> ;         ...

  7. Servlet个人总结

    netstat -an ——查看端口占用情况 netstat -an ——查看是谁占用了哪个端口 端口被占用之后可以关闭端口占用程序或者在conf/server.xml修改本身使用端口 javac - ...

  8. oh my zsh命令

    打开某个文件夹地址,输入 cdf   命令,会自动进入这个文件夹命令行 open ./      打开当前命令行所在目录的文件夹

  9. poj2752 水题

    又2b了一次…… var s:ansistring; ans,pre:..] of longint; i,k,tot:longint; procedure main; begin pre[]:=;k: ...

  10. 算法的时间复杂度(大O表示法)

    定义:如果一个问题的规模是n,解这一问题的某一算法所需要的时间为T(n),它是n的某一函数 T(n)称为这一算法的“时间复杂性”. 当输入量n逐渐加大时,时间复杂性的极限情形称为算法的“渐近时间复杂性 ...