Try looking at your if statements like this:
CODE
if (name1.compareTo(name2) >0)
orderStr = name1 +" " + name2+" " +name3;
else
if (name1.compareTo(name3) >0)
orderStr = name3 +" " + name2+" " +name1;
else
if (name2.compareTo(name3) >0)
orderStr = name1 +" " + name2+" " +name3;
else
if (name2.compareTo(name1) >0)
orderStr = name1+" " + name2+" " +name3;
else
if (name3.compareTo(name1) >0)
orderStr = name1 +" " + name2+" " +name3;
else
if(name3.compareTo(name2) >0)
orderStr = name1 +" " + name2+" " +name3;
What an if statement does is check for a conditiona that is either determined to be true or fales. If the condition is true, then the code under the if statement is executed, if it is false, then it is not. Nested if statements are special in that they can be used to check cases with increasing detail. So, for example, if the first statement is false, the code under the else statement will be executed (which happens to be another if statement).
Your problem here is that if the first if statement is true, then none of the other code is ever looked at. To prove this, enter the following names into your program:
CODE
Zeb
Anthony
Mark
These names will not be printed out in the same order that they were inputted, but they may still not be right.
What you need to do, is to be able to check all three names in one if statement instead of only two.
One way to do this would be to use the && operator.
For instance:
CODE
if(name1.compareTo(name2) > 0 && name2.compareTo(name3) > 0)
//then set your string to whatever you want
See what you can do with this. Good luck.