Answer:
import java.util.Scanner;
public class InsectGrowth {
public static void main (String [] args) {
int numInsects = 8;
while(numInsects < 100){
System.out.print(numInsects+" ");
numInsects = numInsects *2;
}
System.out.println();
}
}
Explanation:
Create the main function and define the variable numInsects with value 8.
Take the while loop and it run until numInsects less than 100.
Inside the loop. first print the value and less double the numInsects value.
for example:
suppose, numInsects = 2
the, check condition 2 < 100, true
print(2)
numInsects = 2* 2=4
second time, numInsects = 4
the, check condition 4 < 100, true
print(4)
numInsects = 4* 2=8
and so on, until numInsects < 100.
Print each number with space and finally when the loop is terminate print the new line.