Comparing 3 or more numbers

Hello there,

I'm new to Java and I've recently been wondering how you compare 3 or more numbers that a user inputs.

Basically I referenced a Scanner, and created three int variables which the user inputs. Now how would you display which is the largest and which is the smallest? I know you could make a bunch of if statements, but what would be the most efficient way of doing this?

I'm new to Java and I've recently been wondering how you compare 3 or more numbers that a user inputs.

Basically I referenced a Scanner, and created three int variables which the user inputs. Now how would you display which is the largest and which is the smallest? I know you could make a bunch of if statements, but what would be the most efficient way of doing this?

You haven't quite followed the example given, Math.max() only takes two parameters whilst you have attempted to use three.
As only two are permitted, then we need to call max() twice, first to compare two numbers, then to compare the third with the larger one found previously.

I refer back to my previous code:

Java Code:

Math.max(a, Math.max(b, c));

See if you can spot it ;).
Once you have solved this, the same applies to finding the min.