import java.util.*;
import java.lang.*;
import java.io.*;

// The main method must be in a class named "Main".
class Main {
    public static void main(String[] args) {
        int[] num={15,22,29,35,40,-15,35};
        //calculate sum of all array elements
        Double sum = 0.00;
        for(int i=0; i < num.length; i++)
        sum = sum + num[i];
        //calculate average value
        Double average = sum / num.length;
        
        System.out.println("average value of the array elements is:"+ average);
    }
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: