I am currently studying java and am doing the task of creating the title program. I want to randomly create an array with 50 elements, then output a number greater than or equal to the input integer, and then start a new line and output a number less than the input integer, but that doesn't work. Can you give me some advice on where to fix it?
class test17 {
public static void main(String[] args) {
int[] array = PConsole.createRandomIntArray(1, 300, 50, true);
int th= PConsole.inputIntNum(1, 300); //Threshold
int upper = array[0];
int lower = array[1];
for (int i = 0; i < array.length; i++) {
if ( array[i]>= th) {
upper+= array[i]+" ";
}else{
lower+= array[i]+" ";
}
}
System.out.println(th);
System.out.println(upper);
System.out.println(lower);
}
}