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


            }
}

Recommended Answers

All 2 Replies

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.

what you actually want to do ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.