import java.io.*;
class SumAndAverageofArray
{
public static void main(String args[])
{
BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
int arr[];
arr=new int[10];
System.out.println("Enter The Elements of array");
for(int i=0;i<=9;i++)
{
try
{
arr[i]=Integer.parseInt(bf.readLine());
}
catch(Exception e)
{
e.printStackTrace();
}
}
int sum=0,i=0;
for( int j=0;j<10;j++)
sum=sum+arr[j];
double average=sum/10.0;
System.out.println("Sum of elements of array="+sum);
System.out.println("Average of elements of array="+average);
}
}
class SumAndAverageofArray
{
public static void main(String args[])
{
BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
int arr[];
arr=new int[10];
System.out.println("Enter The Elements of array");
for(int i=0;i<=9;i++)
{
try
{
arr[i]=Integer.parseInt(bf.readLine());
}
catch(Exception e)
{
e.printStackTrace();
}
}
int sum=0,i=0;
for( int j=0;j<10;j++)
sum=sum+arr[j];
double average=sum/10.0;
System.out.println("Sum of elements of array="+sum);
System.out.println("Average of elements of array="+average);
}
}
Comments
Post a Comment