"Write a loop that reads positive integers from console 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."

Respuesta :

ijeggs

Answer:

import java.util.Scanner;

public class num10 {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       int num;

       String nums =" ";

        do{

           System.out.println("Enter positive numbers");

           num = in.nextInt();

           if(num>100){

              nums = nums+num+" ";

           }

       }while(num>0);

       System.out.print(nums);

   }

}

Explanation:

  • The implementation is in Java programming language
  • Import SCanner and create an object of it to receive user input
  • Create an int variable num to hold the values of num
  • Create another variable a string to hold numbers greater than 100
  • Using a do-.....while statement, continually prompt a user for a number, loop terminates whenever number is less than or equal to zero
  • Within the do.....while statement, add any value of num that is greater than 100 using an if statement.