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. cf 357C

    比赛的时候纯暴力超时了  看了别人的代码  set容器类做的   stl里还是有很多好东西的 /**************************************************** ...

  2. 如何在CHROME里调试前端代码?

    以前看前端们调得很神的, 刚看书到这里,作一个记录,演练了一下,确实有点神!!! :) <!DOCTYPE html> <html lang="en"> & ...

  3. hdu 1849 Rabbit and Grass 博弈论

    水题,转化Nim 代码如下: #include<iostream> #include<stdio.h> #include<algorithm> #include&l ...

  4. SQLite入门与分析(四)---Page Cache之事务处理(3)

    写在前面:由于内容较多,所以断续没有写完的内容. 11.删除日志文件(Deleting The Rollback Journal)一旦更改写入设备,日志文件将会被删除,这是事务真正提交的时刻.如果在这 ...

  5. ArcGIS学习记录—dbf shp shx sbn sbx mdb adf等类型的文件的解释

    原文地址: ArcGIS问题:dbf shp shx sbn sbx mdb adf等类型的文件的解释 - Silent Dawn的日志 - 网易博客 http://gisman.blog.163.c ...

  6. 120. Triangle

    题目: Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjace ...

  7. P151、面试题27:二叉搜索树与双向链表

    题目:输入一棵二叉搜索树,将该二叉搜索树转换成一个排序的双向链表.要求不能创建任何新的结点,只能调整树中结点指针的指向.(本质是中序遍历)二叉树结点的定义如下:struct BinaryTreeNod ...

  8. Linux的分段和分页机制

    1.分段机制 80386的两种工作模式  80386的工作模式包括实地址模式和虚地址模式(保护模式).Linux主要工作在保护模式下. 分段机制  在保护模式下,80386虚地址空间可达16K个段,每 ...

  9. sed找到重复的行

    sed之仅打印相邻重复的行 cat file  aaa bbb bbb ccc ddd eee eee fff   只显示重复的行: bbb bbb eee eee   sed -n ':a;N;/\ ...

  10. 取出block所对应的hash值

    /**********************************************************************//** Gets the hash value of t ...