
this program is accepting only integers as input but i want to modify it such that it can accept both integers and char. import java.util.*; public class Insertion1 { public static void insertion_srt(int array[],int n){ for (int j = 0; j < n; j++){ int i = j-1; int k = array[j]; while ((i>= 0) && (array[i] > k)){ array[i+1]=array[i]; i=i-1; array[i+1]=k; } } } public static void main(String a[]){ Scanner input=new Scanner(System.in); int array[]=new int[10]; int i;
System.out.println(" Selection Sort\n\n");
System.out.println("Values Before the sort:\n");
for(i = 0; i < array.length; i++){
array[i]=input.nextInt();
}
for(i = 0; i < array.length; i++){
System.out.println(array[i]);
}
insertion_srt(array, array.length); System.out.println("PAUSE");
}
}
System.out.print("Values after the sort:\n");
for(i = 0; i
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.