2011-12-14 14:16:36
0
i would like to display letters ether they are in ascending order or not in ascending order, i'm having problem to compare the array's index. in this case i'm using bubble sort technic and modify them.
public class Main
{
public static void main(String[] args)
{
System.out.print( "#Enter text : " );
String text = BIO.getString();
while ( ! text.equals( "END" ) )
{
boolean inorder = false;
// Convert the above string to a char array.
char[] arr = text.toCharArray();
for (int i=0; i
{ //Check pair
if ( arr[i] > arr[i+1] )
{
System.out.print("letters in ascending order");
inorder = true;
}
}
if ( ! inorder )
{
System.out.print("letters not in ascending order");
}
break;
}
}
}