Java编程、输入数字个数、平均数、最小值、最大值减去最小值、write a JAVA program to read in a sequence of integers and print out the following quantities,each on a new line and in the following order,your program should be:1)

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/14 14:34:10
Java编程、输入数字个数、平均数、最小值、最大值减去最小值、write a JAVA program to read in a sequence of integers and print out the following quantities,each on a new line and in the following order,your program should be:1)

Java编程、输入数字个数、平均数、最小值、最大值减去最小值、write a JAVA program to read in a sequence of integers and print out the following quantities,each on a new line and in the following order,your program should be:1)
Java编程、输入数字个数、平均数、最小值、最大值减去最小值、
write a JAVA program to read in a sequence of integers and print out the following quantities,each on a new line and in the following order,your program should be:
1) the number of integers read in.
2) the average value- which need not be an integer.注意,平均值不是实数!
3) the minimum value of the integers.
4) the maximum difference between any of the integers.
以上要求顺序不能颠倒、跪求!

Java编程、输入数字个数、平均数、最小值、最大值减去最小值、write a JAVA program to read in a sequence of integers and print out the following quantities,each on a new line and in the following order,your program should be:1)

这是源代码,直接考到本地即可运行:

package com.cc.test;

import java.util.Scanner;

public class Test {

public static void main(String[] args) {

Scanner scan = new Scanner(System.in);

Test test = new Test();

test.print("Input Num Count:");

int count = scan.nextInt();

int[] data = new int[count];

for (int i = 0; i < count; i++) {

data[i] = scan.nextInt();

}

test.output(data);

}

private void print(String info) {

System.out.print(info);

}

private void println(String info) {

System.out.println(info);

}

/**

 * 取得首个最小值和最大值.

 * 

 * @param data

 */

private void output(int[] data) {

DataInfo maxData = new DataInfo(Integer.MIN_VALUE, -1);

DataInfo minData = new DataInfo(Integer.MAX_VALUE, -1);

int posTemp = -1;

double total = 0;

for (int dataTemp : data) {

posTemp++;

total += dataTemp;

if (dataTemp > maxData.getValue()) {

maxData.setValue(dataTemp);

maxData.setPos(posTemp);

}

if (dataTemp < minData.getValue()) {

minData.setValue(dataTemp);

minData.setPos(posTemp);

}

}

this.printDataInfo(data, total, maxData, minData);

}

private void printDataInfo(int[] data, double total, DataInfo maxData,

DataInfo minData) {

int length = data.length;

double average = total / length;

this.println("the number of integers read in:" + length);

this.println(" the average value- which need not be an integer:"

+ average);

this.println("the minimum value of the integers:" + minData.getValue()

+ " Pos:" + minData.getPos());

this.println("the maximum difference between any of the integers:"

+ (maxData.getValue() - minData.getValue()));

}

private class DataInfo {

int value;

int pos = -1;

public DataInfo(int value, int pos) {

this.value = value;

this.pos = pos;

}

public int getValue() {

return value;

}

public void setValue(int value) {

this.value = value;

}

public int getPos() {

return pos;

}

public void setPos(int pos) {

this.pos = pos;

}

}

}

Java编程、输入数字个数、平均数、最小值、最大值减去最小值、write a JAVA program to read in a sequence of integers and print out the following quantities,each on a new line and in the following order,your program should be:1) Java编程、输入数字个数、平均数、最小值、最大值减去最小值、write a JAVA program to read in a sequence of integers and print out the following quantities,each on a new line and in the following order,your program should be:1) Java输入一系列 数字求奇数、偶数、0的个数 C语言编程,输入10个数字计算平均数,并输出大于平均数的元素 从控制输入n个数,计算n个数中偶数的平均数,java如何实现 JAVA编程,输入一个四位数,求四位数的每位数字之和!是JAVA,不是C语言! java编程题:输入三角形行数打印数字三角形.如输入5,打印:1 12 123 1234 12345 求一个C语言编程 输入N个数 求最大值 最小值 平均数 求java程序:输入n个正整数,分成两组求和,求两列数字组合使这两组的和最接近平均数实用价值:商场打折.如:满500返500注意:每组的数字个数不确定(如输入10个数,可能会产出2个数的和跟 怎样在JAVA编程中输入一个数字输出这个数字的拼音?例如:9 jiu19 shi jiu102 yi bai ling er vfp的一道编程题,输入任意的几个数,输出最大值、最小值、总和、平均数.如题 C语言编程:输入一行字符,至少50个,统计其中英文字母,数字,其他字母个数 C语言程序题:任意输入十个数,输出最大最小和平均数,这个程序咋么写啊? 如何用C语言求平均数?输入数据个数不定!我要求不需要输入数字个数啊... 用JAVA编程从键盘输入一个正整数,计算该数的各位数字之和并输出,例如输入数是5246 让大家一个java非常简单的编程:根据输入1到12之间的数字,判断是春夏秋冬哪个季节要求使用方法定义四个季节 java编程,输出3个数中的最大值和最小值 java编程:用户从键盘上输入10个数,分别统计正数、负数、零的个数、平均值、累加和.用户从键盘上输入一个数,程序判断这个数是不是素数,并输出结果.求这两个java编程的写法啊