Question

# Share code with your friends

Share on whatsapp

Share on facebook

Share on twitter

Share on telegram

Code

` ````
```import java.util.Scanner;
public class program5
{
public static void main(String[]args)
{
int i=0,j=0,temp=0;
Scanner sc = new Scanner(System.in);
int[] weights = new int[10];
System.out.println("Enter weights: ");
for (i = 0; i < 10; i++)
{
weights[i] = sc.nextInt();
}
for (i = 0; i < 10; i++)
{
for (j = i+1; j < 10; j++)
{
if (weights[i] < weights[j])
{
temp = weights[i];
weights[i] = weights[j];
weights[j] = temp;
}
}
}
System.out.println("Sorted weights:");
for (i = 0; i < 10; i++)
{
System.out.println(weights[i]);
}
}
}