WAP in java to accept 10 number in a single dimension array and print the bubble short of it....
......plz help me out
Answers
import java.util.*;
class Bubble
{
public static void main()
{
Scanner sc=new Scanner(System.in);
int i,j,t=0;
int m[]=new int[5];
for(i=0;i<m.length;i++)
{
System.out.println("Enter your elements");
m[i]=sc.nextInt();
}
for(i=0;i<m.length-1;i++)
{
for(j=0;j<m.length-1-i;j++)
{
if(m[j]<m[j+1])
{
t=m[j];
m[j]=m[j+1];
m[j+1]=t;
}
}
}
System.out.println("Sorted array is");
for(i=0;i<m.length;i++)
{
System.out.println(m[i]);
}
}
}