Task: Write a Java program to Find Sum and Average of Array in Java.

First of all, the user will input 5 numbers of type double in array. After this, the Java program will calculate sum and average of the numbers in array.

### The source code of Java Program to find Sum and average of Array

/* * Write a Java program to input 5 double values in an array. find total and average of these values. */ package totalaverage; /** * @author www.EasyCodebook.com */ import java.util.Scanner; public class TotalAverage { public static void main(String[] args) { Scanner input= new Scanner(System.in); double a[]=new double[5]; double sum=0.0, average; int i; for(i=0;i<5;i++) { System.out.print("Enter number in Array="); a[i]=input.nextDouble(); sum = sum + a[i]; } average = sum / 5.0; System.out.println("Sum ="+sum+ " and Average="+average); } }