I need help so i was doing some random generation numbers for our class
I needed to generate 3 random numbers but then it said i need to use math.min process and make the 3 numbers output in ascending order
And i can't seem to i kept reading about math.min and I'm still confused now
Btw here's the code but it's just for the random num generation
import java.util.*; import java.lang.Math; class GenNumber{ public static void main(String[] args) { double Lowest,Mid,Max; double x=0, y=0, z=0; int num; Random rnum = new Random(); System.out.println("Random Numbers:"); System.out.println("***************"); for (num = 1; num <= 3; num++) { System.out.println(rnum.nextInt(100)); { if(num == 1) x = rnum.nextInt(100); }{ if(num == 2) y = rnum.nextInt(100); }{ if(num == 3) z = rnum.nextInt(100); } } Lowest = Math.min(x,y); Lowest = Math.min(Lowest, z); Mid = Math.max(Lowest, x); Mid = Math.max(Mid, y); Mid = Math.max(Mid,z); Max = Math.max(x, y); Max = Math.max(Max, z); System.out.println("sorted random numbers:"+x, y, z); } }
I also tried storing them through x y and z but i still have no luck figuring it out.