Given positive integer numInsects, write a while loop that prints that number doubled without reaching 200. Follow each number with a space. After the loop, print a newline. Ex: If numInsects = 16, print:16 32 64 128 import java.util.Scanner;public class InsectGrowth {public static void main (String [] args) {int numInsects;Scanner scnr = new Scanner(System.in);numInsects = scnr.nextInt(); // Must be >= 1/* Your solution goes here */}}

Respuesta :

Answer:

The below code is pasted in the place of "/*Your solution goes here */"

while(numInsects<200) // while loop

       {

            System.out.print(numInsects+" "); // print statement

            numInsects=numInsects*2; // operation to print double.

       }

Output:

  • If the user gives inputs 16 then the output is 16 32 64 128.
  • If the user gives inputs 25 then the output is 25 50 100.

Explanation:

  • The above code is in java language in which the code is pasted on the place of "Your solution" in the question then only it can work.
  • Then the program takes an input from the user and prints the double until the value of double is not 200 or greater than 200.
  • In the program, there is while loop which checks the value, that it is less than 200 or not. If the value is less the operation is performed otherwise it terminates.
fichoh

Using Python 3 programming, the code blocks below displays the required instructions. The program goes thus :

numInsects = int(input())

#takes input from the user on the number of insects

while numInsects < 200 :

#while loop checks if variable is below 200

print(numInsects, end=' ')

#displays the value with the cursor remaining on the same line

numInsects*=2

print(numInsects)

Learn more : https://brainly.com/question/12483071