HW6.4

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的更多相关文章
- HW6.30
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW6.29
public class Solution { public static void main(String[] args) { int count = 0; int[] card = new int ...
- HW6.28
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW6.27
import java.util.Scanner; import java.util.Arrays; public class Solution { public static void main(S ...
- HW6.26
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW6.25
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW6.24
public class Solution { public static void main(String[] args) { int count = 0; int color; int numbe ...
- HW6.23
public class Solution { public static void main(String[] args) { boolean[] box = new boolean[101]; f ...
- HW6.22
import java.util.Arrays; public class Solution { public static void main(String[] args) { int[][] ch ...
- HW6.21
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
随机推荐
- Kafka 之 async producer (1)
问题 很多条消息是怎么打包在一起的? 如果消息是发给很多不同的topic的, async producer如何在按batch发送的同时区分topic的 它是如何用key来做partition的? 是如 ...
- android下调试unity3d应用
原地址:http://blog.csdn.net/armoonwei/article/details/7032455 目前貌似不支持断点调试,但可以通过日志打印(logcat)来跟踪. 在androi ...
- jquery 请求jsp传递json数据的方法
$(function() { $("a[name=hrefID]").click(function() { var id = $(this).attr("id" ...
- 1990-D. 幻方
描述 河图,黑点白点排列奥秘数阵:洛书,纵横斜三条线上数和皆15.这是一个古老的数字游戏,将1~9填入一个九宫格,使得每行.每列.对角线上数字的和都相同(为15).在西方,满足类似规律的矩阵称之为幻方 ...
- Tarjan+模板
#include<stdio.h> #include<string.h> #include<stdlib.h> #include<math.h> #in ...
- 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 ...
- 不同VLAN之间互相通信
前话 我们经常到机房上课,想必对机房后面那层叠的跟DVD一样的机器有印象吧,那些就是交换机. 交换机作用是什么? 我这里度娘一下: 交换机(Switch)意为"开关"是一种用于电( ...
- 使用intellij idea搭建MAVEN+springmvc+mybatis框架
原文:使用intellij idea搭建MAVEN+springmvc+mybatis框架 1.首先使用idea创建一个maven项目 2.接着配置pom.xml,以下为我的配置 <projec ...
- Eclipse字体修改设置
修改字体 Window -> Preferences -> General -> Appearences -> Colors and Fonts 选择java选项,看到Java ...
- 221. Maximal Square
题目: Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and ...