0

Hi my codes works fine.When i key in ,for example, asdf 546,(f and 5 is separated by space), the programe rightly take it as invalid input ,however it takes asdf and 546 as separate type and return two "Invalid input".See below.

I hav no clue why it does that oher than it being something with the nextLine.How can i get it to see asdf 546 is one input value?**output**

How many integers shall we compare? (Enter a positive integer):

3

Enter value 1:55

Enter value 2:**asdf 546**

Invalid input!

Enter value 2:**Invalid input!**

Enter value 2:

23

Enter value 3:-13

The smallest number entered was: -13

My code

```
for (value = 1;value<=ii; value++)
{
System.out.print("Enter value " + value + ":");
while (!input.hasNextInt())
{
System.out.println("Invalid input!");
input.nextLine();
System.out.println("Enter value " + value + ":");
}
randomNum = input.nextInt();
if ( value == 1 )
smallest = randomNum;
else if (randomNum < smallest)
smallest = randomNum;
}
System.out.println("The smallest number entered was: " + smallest);
}
```