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. hdu 1176

    简单DP  类似于在一个矩形中求最长路径 /************************************************************************* > ...

  2. Data transfer object

    Data transfer object (DTO) is a design pattern used to transfer data between software application su ...

  3. use sql trigger call java function

    Use UDF sys_exec to do this. You can use this link to use sys_exec function. It says, sys_exec sys_e ...

  4. CF 136A Presents

    http://codeforces.com/problemset/problem/136/A 题意 :就是输入很多数字,第 i 个数字 pi 代表着第 i 个人的礼物给了第 pi 个人,而让你输出的数 ...

  5. Java中JSON的简单使用与前端解析

    http://www.blogjava.net/qileilove/archive/2014/06/13/414694.html 一.JSON JSON(JavaScript Object Notat ...

  6. java:复写equals实例

    class User { String name; int age; /* *比较过程思路: *1.两个对象指向位置相同,那么他们就相等,return后跳出函数,不再往下执行 *2.指向位置不同,有3 ...

  7. POJ1850——Code(组合数学)

    Code DescriptionTransmitting and memorizing information is a task that requires different coding sys ...

  8. Firefox Security Toolkit 安装

    目的: 下载Firefox Security Toolkit加载到浏览器里,增强渗透测试的工具利用. 兼容性: 目前仅支持Linux/Unix环境(可在kali上安装使用). 下载安装: wget h ...

  9. SQL Server常见问题总结

    写在前面 在QQ群,微信群,论坛中经常帮助使用SQL Server数据库的朋友解决问题,但是有一些最常见最基本的问题,每天都有人问,回答多了也不想再解答了,索性把这些问题整理一下,再有人问到直接发链接 ...

  10. RazorEngine(未解决,留底)

    TemplateServiceConfiguration templateConfig = new TemplateServiceConfiguration { BaseTemplateType = ...