I am trying to establish a code where a user inputs any 5numbers (integers) into a list. I am tasked with getting this codeto function where the numbers return in ascending order, however, Icannot use any sort functions. Could you help me with this please.Thanks!
Answer
import java.util.Arrays;
import java.util.Scanner;
public class TestList {
public static void main(String[] args) {
int arr[]=getNumbers();
System.out.println(Arrays.toString(arr));
}
private static int[] getNumbers() {
Scanner sc = new Scanner(System.in);
System.out.println(“Enter 5 elements”);
int arr[]=new int[5];
for(int i=0;i<5;i++)
arr[i]=sc.nextInt();
sort(arr);
return arr;
}
public static void sort(int array[]) {
int i, j, temp;
int count= array.length;
for(i = 0; i < count-1;