8.7k views
4 votes
Write a loop that reads positive integers from standard input, printing out those values that are greater than 100, and that terminates when it reads an integer that is not positive. the values should be separated by single blank spaces. declare any variables that are needed.

User Lianna
by
7.8k points

1 Answer

4 votes
Thank you for posting your question here. Below is the answer, I hope it helps.

int number = 0;

while (stdin.hasNextInt() && number >= 0){
number =stdin.nextInt();
if (number > 100)
System.out.print(number + " ");
}
User CheesePls
by
8.3k points