First off, I have a compiling error that reads " 'else' without 'if'. " I don't really understand what it's trying to tell me. Here's my program:
public class NumberSorter
{
public NumberSorter()
{
//No body necessarry
}
public static void SortIt(double x, double y, double z)
{
if(x < y && x < z)
{
if(y < z)
{
System.out.println(x);
System.out.println(y);
System.out.println(z);
}
else
{
System.out.println(x);
System.out.println(z);
System.out.println(y);
}
else if(y < x && y < z)
{
if(x < z)
{
System.out.println(y);
System.out.println(x);
System.out.println(z);
}
else
{
System.out.println(y);
System.out.println(z);
System.out.println(x);
}
}
else if(z < x && z < y)
{
if (x < y)
{
System.out.println(z);
System.out.println(x);
System.out.println(y);
}
else
{
System.out.println(z);
System.out.println(y);
System.out.println(x);
}
}
}
}
If you can't tell already, I'm trying to implement a class in which it can sort three numbers from least to greatest. The editor just keeps telling me that there's a problem with my "else if" part. As I've said before, I don't really understand this, and I would deeply appreciate if you can help me out. Oh yeah I probably won't get a chance to thank each one of you individually for helping me out, so I just want to say "THANK YOU SO MUCH"- for at least trying an attempt to help me.