Home Write a program to input 10 numbers into an integer array and interchange the largest number with the smallest number within the array and print the modified array. Assume that there is only one largest and smallest number. byJAVA EXPERT •April 11, 2022 • 2 min read 0 import java.util.*;class Sol9{ static void main() { Scanner sc=new Scanner(System.in); int a[]=new int[10],i,l=0,s=0; System.out.println(“Enter 10 numbers:”); for(i=0;i<10;i++) a[i]=sc.nextInt(); l=s=a[0]; for(i=1;i<10;i++) { if(a[i]>l) l=a[i]; if(a[i]<s) s=a[i]; } for(i=0;i<10;i++) { if(a[i]==l) a[i]=s; else if(a[i]==s) a[i]=l; } System.out.println(“Modified Array:”); for(i=0;i<10;i++) { System.out.print(a[i]+“ ”); } } } 4.94 / 169 rates Facebook Tweet CopyLink Copied Share