Respuesta :
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
Answer:
num_insects = num_insects
while num_insects <= 100:
print(num_insects,'', end='')
num_insects = num_insects * 2
Explanation:
Python. You must define num_insects first. Then make sure you put while to make it a loop. Print goes next follwed by end='', this is to make sure there is an end to your loop. also don't forget the space between the answer and the end=''. Then the next step will be to double it. This will play out until it reaches 100.