For double highest = Double.MIN_VALUE;
, instead use -Double.MAX_VALUE
. Note the ‘-‘ sign.
And for :
if (num > highest)
{
highest = num;
}
Use:
highest = Math.max(highest, num)
lowest = Math.min(lowest, num)
3
solved Finding the Highest and Lowest in the entered 10 numbers