Skip to content
Advertisement

Find the highest, second highest, and lowest of three random generated numbers without using conditional statements

As a 1st year college IT student, I have a Java assignment where I must display three random generated numbers and order them highest, second highest, lowest. The challenge given by our professor is to not use any conditional statements or arrays.

Here is the code:

JavaScript

The problem I am facing is that I am struggling to get the “in-between” value of the highest and lowest. Is there any “in-between” variable for me to get the second highest without using any conditional statement or array?

Advertisement

Answer

You can do this:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement