A program that outputs a number greater than or equal to the input integer and a number less than the input integer from an array with 50 elements.

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);
    }
}       

Recommended Posts

A program that outputs a number greater than or equal to the input integer and a number less than the input integer from an array with 50 elements.
A program (Java) that outputs the sum of odd and even numbers in an array
A program that determines whether the entered integer is close to an integer
[Java] Program example to get the maximum and minimum values from an array
[Ruby] I want to make an array from a character string with the split method. And vice versa.
[Java] How to search for a value in an array (or list) with the contains method
A program that calculates factorials from 2 to 100
I tried to make a program that searches for the target class from the process that is overloaded with Java
[Swift] How to get the number of elements in an array (super basic)
How to get an arbitrary digit from a number of 2 or more digits! !!
Be careful when deleting multiple elements from an array etc. with a for statement
A method that applies transforms in parallel to all elements and returns an array of return values that maintain their order
How to output standard from an array with forEach
[Ruby] Extract only the elements that match the conditions and create a new array. filter and select
I want to return a type different from the input element with Java8 StreamAPI reduce ()
A program that searches for a character string, and when the search character string is found, displays the character string from the beginning of the line to just before the search character string.