It compiles and runs fine, but when I run it it never ends. It keeps asking for a second integer. Here's the code.

Scanner get = new Scanner ( );
                    System.out.print( "Please enter first integer: " );
                    int value = get.nextInt();
                    int smallest = value;
                    int largest = value;
                    for (int count = 0; count < 7; count++ )
                            System.out.println ( "Enter the second integer" );
                            value = get.nextInt();
                            System.out.println( "Enter the third integer" );
                            value = get.nextInt();
                            if ( value > largest ) largest = value;
                            if ( value < smallest ) smallest = value;
                            System.out.printf( "%d:%d",smallest, largest );

You have a for loop that will prompt you for 2nd and 3rd input for a total of 7 times. Not sure why you glhave those two additional prompts if you are only checking after prompt 3

Well, I was just testing it and the total number of integers it asks me for is 8, so I figured i got the one up top and there is 7 more to go. So should i just remove the for statement or what do i do with it.

Inside the loop the print out statement should be Enter integer, the loop will ask this question the number of times you have stored in the loop, you will then assign the ints to an array and compare the values

int[] value = new int[7];

Scanner get = new Scanner ( );
 for (int count = 0; count < value.length; count++ ){

                    System.out.print( "Please enter integer: " );
                    value[i] = get.nextInt();


that should get you started

Edited 2 Years Ago by tricket_7: error in post

This article has been dead for over six months. Start a new discussion instead.