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. iOS开发的小技巧(断点打印)

    iOS开发中我们会碰到这样的需求:打印沙盒目录,打印对象信息,对象信息可以通过断点查看,有时候对象属性繁多时看起来又比较麻烦. 今天学到一个比较实用的方法: 在运行时打一个断点,当程序停在这个断点后, ...

  2. Android:仿微信开场切换界面

    这实例很多人仿做,好实例还是不容错过!最重要是素材容易拿~ 效果: 默认3页面的切换,最后一个页面带按钮,点击进入另外一个页面 思路: 1.准备5个布局页面,1个为主函数布局页面,3个为切换的页面(其 ...

  3. Django Navi 重用

    代码来自这里: base.html <html> <head>...</head> <body> ... {% block nav %} <ul ...

  4. 手动添加 memcached.jar包

    由于目前java memcached client没有官方的maven repository可供使用,因此使用时需要手动将其安装到本地repository. java memcached client ...

  5. 泛型编程、STL的概念、STL模板思想及其六大组件的关系,以及泛型编程(GP)、STL、面向对象编程(OOP)、C++之间的关系

    2013-08-11 10:46:39 介绍STL模板的书,有两本比较经典: 一本是<Generic Programming and the STL>,中文翻译为<泛型编程与STL& ...

  6. CodeIgniter类库之Benchmarking Class ,计算代码的执行时间

    CodeIgniter中有个Benchmarking类库,它是被系统自动被加载的,不需要手工加载.Benchmarking类库能够计算出任意两个被标记点之间的代码执行时间.通过这个数值,可以评估程序员 ...

  7. WIN7 XP设置MTU,提升下载速度

    可能很少有雷友注意过“本机.网络”的“MTU”值对自己网络性能产生的影响.对于追求更快的下载速度来说,MTU值设置不当,就仿佛穿着高跟鞋跑步一般. MTU是什么? “MTU=最大传输单元 单位:字节” ...

  8. IMX51启动模式

    相关链接: http://blog.csdn.net/kickxxx/article/details/7236040 http://blog.csdn.net/evilcode/article/det ...

  9. ibeacons社区

    http://www.idropbeacon.com http://www.chinaibeacons.com http://iwebad.com/tag/ibeacon http://www.cng ...

  10. Java多线程性能优化

    大家使用多线程无非是为了提高性能,但如果多线程使用不当,不但性能提升不明显,而且会使得资源消耗更大.下面列举一下可能会造成多线程性能问题的点: 死锁 过多串行化 过多锁竞争 切换上下文 内存同步 下面 ...