Saturday, April 12, 2014

Simple Array Program in Java


import java.util.*;
public class ArrayOrder
{
public static void main(String args[])
{
Scanner s=new Scanner(System.in);
int a []={25,95,65,74,18};
int temp=0;
int sum=0;
double avg=0;
double S=0;
for(int i=0;i for(int j=0;j {
if(a[j]>a[j+1])
{
temp=a[j+1];
a[j+1]=a[j];
a[j]=temp;
}
}
for(int b=0;b {
sum=sum+a[b];
avg=sum/a.length;
System.out.println(a[b]);
S=S+Math.pow((a[b]-avg),2);
}
System.out.println("Meadian is: "+a[a.length/2]);
System.out.println("minimum is: "+a[0]);
System.out.println("Summation is: "+sum);
System.out.println("Average is: "+avg);
System.out.println("sd is:"+Math.sqrt(S/a.length-1));
}
}