1.

write a program input city and temperature and sort according to city using bubble sort method using buffered Reader​

Answer»

tion:import java.io.*;class CitySort{public static void MAIN (String ARGS[]) throws IOEXCEPTION{int n,len,LEN1,c,i,j,k=0,m=0;String str[]=new String[5] ;String s1;String s2,temp;BufferedReader br = new BufferedReader(new InputStreamReader(System.in));for (i=0;i<5;i++){System.out.println(“Enter the string “+i+” of the Array :=> “);str[i]= br.readLine();}System.out.println(“\nSorted Strings are :-”);for(i=0;i<5;i++){for(j=i+1;j<5;j++){if(str[j].compareTo(str[i])<0){temp=str[i];str[i]=str[j];str[j]=temp;}}System.out.println(str[i]);}}}



Discussion

No Comment Found