0

I hav this code here that prompt me for only 1 randomNum.I know i need a second loop.how can i go about doing it

 public static void main(String[] args) {

        int ii=0;
        int value;
        int randomNum;


            System.out.println("How many integers shall we compare? (Enter a positive integer):");
            ii = input.nextInt();
            randomNum =input.nextInt();

            for (value = 1;value<=ii; value++)   

            if(ii !=0 && ii > 0){
                System.out.println("Enter value " + value + ":"+ randomNum );
            }
            else
            {
                System.out.println("Invalid input!");
            }


            }
}
3
Contributors
2
Replies
3
Views
4 Years
Discussion Span
Last Post by prnjn
0

Please explain what you need a second loop for. What is the code supposed to do? What does it do now?

One problem with your code is that it is not properly formatted. You should always use {}s with loops and if statement to contain the code within those statements. Each nesting level in the code should be indented 3-4 spaces.

Edited by NormR1

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.