Code Below:
import java.util.*;
class word_sort
{
public static void main()
{
Scanner s=new Scanner(System.in);
System.out.println("Enter the word");
String st=s.next();
st=st.toUpperCase();
char ch;
String aw="",dw="";
for(int i=65;i<=90;i++)
{
for(int j=0;j< st.length();j++)
{
ch=st.charAt(j);
if (ch==i)
{
aw=aw+ch;
dw=ch+dw;
}
}
}
System.out.println("ORIGINAL:"+st);
System.out.println("ASCENDING:"+aw);
System.out.println("DESCENDING:"+dw);
}
}