230k views
3 votes
Write a loop that reads positive integers from standard input, printing out those values that are greater than 100, each on a separate line, the loop terminates when it reads an integer that is not positive.

User RabidFire
by
8.4k points

1 Answer

4 votes
//use java not javascript
Scanner scan = new Scanner(s);
int nums[] = new int[2000];
int value =1;
int index = 0;
\\loop for entering values and save those over 100 in an array
While( value >= 0 ) \\ as long input is positive number loop continues
{

System.out.print("Enter an integer : ");
value = scan.nextInt( );
if(value > 100)
{
nums[index] = value;
index++;
}

}

//Next loop prints the array contents on one line with one space
for( int i =0; i < nums.length; i++)
{
if(nums[i] > 100)
System.out.print(n
User Wazy
by
7.4k points