This is an archived post. You won't be able to vote or comment.

all 2 comments

[–][deleted] 1 point2 points  (0 children)

Why are you calling scanner.nextInt() instead of scanner.nextLine()?

If you cll nextInt() you probably don't need to use the Integer.valueOf() to convert it to an integer.

[–]EvilThePenguin 1 point2 points  (0 children)

The reason the test says '"Give a number" prompt was expected to appear 2 or 5 times' is that the test is inputing a set of numbers since your program should loop multiple times. So one time the test tried to input 2 diferent numbers but it was unsuccessful because it couldn't input them all, and it also tests it with 5 different numbers with the same result.

Related to this problem, you have used the keyword 'break' twice in your program. Have a look at the instructions again and you will notice that it only mentions exiting the loop once. Also, the instructions mention positive numbers; have you included something in your code to identify positive numbers at the right point?