import java.util.Scanner;
public class Array
{
public static void main(String[] args)
{
int a[],n,i,t=0;
double avg;
Scanner sc = new Scanner(System.in);
System.out.println("How many values : ");
n = sc.nextInt();
a = new int[n];
for(i=0; i<n ; i++)
{
System.out.println("Enter Value "+(i+1)+" :");
a[i] = sc.nextInt();
}
for(i=0; i<n ; i++)
{
t = t + a[i];
}
avg = (double)t/n;
System.out.println("Total is "+t);
System.out.println("Average is "+avg);
}
}
OUTPUT
Comments
Post a Comment