📜  计算数组的值 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:10.351000             🧑  作者: Mango

代码示例2
import java.util.Scanner;

public class Main {
    private static Scanner scanner = new Scanner(System.in);
    public static void main(String[] args) {

        Sum arr = new Sum();
        setArraysize(arr,5);
        enterValues(arr);
        System.out.println("Sigma ==> ");
        int sigma = 0;
        sigma = scanner.nextInt();
        calculateSigma(sigma);
        arr.calculateValuesOfArr();
        arr.printSumOfValues();


    }
    public static void setArraysize(Sum arr,int size){
        arr.setArrAndSize(size);
    }

    public static void  calculateSigma(int n){
        Sum sigma = new Sum();
        sigma.sigma(n);
        sigma.printSigma();
    }

    public static void enterValues(Sum arr){
        arr.enterValues();
    }
}