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 ...
随机推荐
- OD之常用命令
一:od断点注释保存的问题,由于od只有在正常退出的情况下才会保存分析代码时留下的注释,而很多时候为了在退出od时不让目标程序退出使用了剥离进程,这样就会导致这次操作所有的注释都没有保存,第二次重新载 ...
- source code analyzer 功能强大的C/C++源代码分析软件 Celerity CRACK 破解版
特色 迅捷是一个功能强大的C/C++源代码分析软件.可以处理数百万行的源程序代码.支持标准及K&R风格的C/C++.对每一个打开的源代码工程,通过建立一个包含丰富交叉引用关系的数据库,显示其所 ...
- SpringMVC ResponseBody返回中文乱码解决方案
@RequestMapping(value = "/getForm") @ResponseBody public List<String> getForm(String ...
- JS 封装类
function HighchartsObj(id, type) { var that = this; this.options = { chart : { renderTo : id, type : ...
- WebViewJavascriptBridge 原理分析
WebViewJavascriptBridge 原理分析 网上好多都是在介绍 WebViewJavascriptBridge如何使用,这篇文章就来说说 WebViewJavascriptBridge ...
- ANDROID_MARS学习笔记_S01_005CheckBox
一. 1.checkbox_layout.xml <?xml version="1.0" encoding="utf-8"?> <Linear ...
- std::remove
#include <algorithm> template< class ForwardIt, class T > ForwardIt remove( ForwardIt fi ...
- meta的Name为apple-itunes-app 是什么意思
例如:<meta name="apple-itunes-app" content="app-id=432274380" /> 解答:这个标签是告诉i ...
- 如何在给快满的Linux分区"无伤"扩容
1. 首先在虚拟机设置里面设置磁盘的扩展,前提条件是该虚拟机没有快照. 2. 在虚拟机设置好以后,需要开机在系统里扩容磁盘 3. 使用 # fdisk /dev/sda 扩展磁盘,具体操作使用 m 选 ...
- VMware Workstation与Hyper-V不兼容。请先从系统中移除Hyper-V角色,然后再运行VMware Workstation。
VMware Workstation与Hyper-V不兼容.请先从系统中移除Hyper-V角色,然后再运行VMware Workstation. 今天在用win8.1的时候发现了这个问题,解决办法如下 ...