Answer:
import java.util.Scanner;
public class CocaColaVendingTest {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter value for number of insects");
int num_insects = in.nextInt();
while (num_insects<=100){
System.out.print(num_insects);
num_insects*=2;
System.out.print(" ");
}
}
}
Explanation:
In the code above written in Java.
The user is prompted to enter a positive value for the number of insects
This is stored in a variable num_insects.
Using a while loop with the condition while (num_insects<=100). The num_insects is printed out. Then it is doubled followed with a space.
It continues until the condition in the while loop is no longer true