31.6k views
4 votes
Given positive integer numinsects, write a while loop that prints that number doubled without reaching 100. follow each number with a space. after the loop, print a newline. ex: if numinsects = 8, print

User Gmuhammad
by
5.8k points

2 Answers

2 votes
Hi,

the program is as follows
___________________________________________________________


import java.io.*;
class doubleval

{
public static void main()throws IOException
{

DataInputStream dt=new DataInputStream(System.in);

System.out.println("Enter NUMBER WHOSE DOUBLE U WANT TO PRINT");
int n=Integer.parseInt(dt.readLine());

for(int i=n;i<=100;i=2*i)
{
System.out.println(i);
}
}
}


User Andy Day
by
5.8k points
4 votes

Answer: while(numInsects < 99) {

printf("%d ", numInsects);

numInsects = numInsects * 2;

}

printf("\\");

Explanation:

User Dalvinder Singh
by
5.4k points