Hi there, I need some help with my output alignment which i cannot get my head around.
My code is the following
Code :import java.io.*; import java.util.*; public class Main{ public static void main(String args[]) { while(true) { System.out.print("#Enter word: "); String word = BIO.getString(); if(word.equals("END") ) break; char[] content = word.toCharArray(); java.util.Arrays.sort(content); String sorted = new String(content); if (sorted.equals(word) ) System.out.printf(word + "Letters in ascending order \n"); else System.out.printf(word + "Letters not in ascending order \n"); } } }
Which using would give an output like this -
almost Letters in ascending order
effort Letters in ascending order
end Letters not in ascending order
knotty Letters in ascending order
known Letters not in ascending order
However i want the output to look like this -
almost letters in ascending order
effort letters in ascending order
end letters not in ascending order
knotty letters in ascending order
known letters not in ascending order
It does not show it properly on forums so here is a print screen.
Attachment 909
The top 2 lines are my current output, the bottom 2 lines are how i want it to look.
As you can see the alingment is all formatted nicely, so it is printed out neatly.
Can someone show me how to do this please
Thanks
