猿问

计算输入数字的总和和平均值,并在 Eclipse 中对数字进行排序

问题:编写一个程序,读取用户的五个整数。程序将计算并输出


以下是关于这五个数字的统计数据:


• The sum of all of the positive numbers (greater than zero).


• The sum of all of the non-positive numbers (less than or equal to zero).


• The sum of all five numbers.


• The average of all of the positive numbers (greater than zero).


• The average of all of the non-positive numbers (less than or equal to zero).


• The average of all five numbers.


这是我的代码:


package assignment_09_20_2018;


import java.util.Scanner ; 


public class LAB_Assignment_09_20_2018 {


    public LAB_Assignment_09_20_2018() {

        // TODO Auto-generated constructor stub



    public static void main(String[] args) {

        // TODO Auto-generated method stub

        int length; 


        Scanner input = new Scanner(System.in) ;

        //opens scanner


        System.out.println("Enter 5 numbers: ") ;


        length = input.nextInt() ; 


        Int[] numbers = new Int[length]



    }

我班上有人说要使用数组和 for 循环,但我不知道如何使用,请帮忙


长风秋雁
浏览 215回答 3
3回答
随时随地看视频慕课网APP

相关分类

Java
我要回答