1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
MrRissso [65]
3 years ago
6

Given positive integer numinsects, write a while loop that prints that number doubled without reaching 100. follow each number w

ith a space. after the loop, print a newline. ex: if numinsects

Computers and Technology
2 answers:
ELEN [110]3 years ago
8 0
Please provide the language you're using when you ask for programming help, otherwise you aren't going to get the answer that you are looking for.

Here it is in Java, and I'm assuming the number is given via user input? Otherwise, just remove the user input function and replace the integer with a value of your choice. Note, that this isn't the full code; only what is relevant to the question.


public static void main(String[] args) {
    int num = numInput(10);
    printDoubles(num, 100);  // You can create a user input function for
                                             // maxValue if you wanted to.
}

/**
 * Receives user input between 0 and the absolute value of maxInput.
 * @param maxInput The largest absolute value that can be input.
 */
private static int numInput(int maxInput) {
    Scanner sc = new Scanner(System.in);

    maxInput = Math.abs(maxInput);

    int num = 0;
    while (!(num > 0 && num <= maxInput)) {
        num = sc.nextInt();

        if (!(num > 0 && num <= maxInput)) {
            System.out.println("Input too small or too large");
        }
    }

    return num;
}

/**
 * Continues to print out num doubled until maxValue is reached.
 * @param num The number to be printed.
 * @param maxValue The maximum value (not including in which num can                                       be doubled to.
 */
private static void printDoubles(int num, int maxValue) {
    if (num >= maxValue) {
        System.out.println("No output.");
    }

    while (true) {
        if (num >= maxValue) {
            break;
        }

        if (num < maxValue) {
            System.out.print(num + " ");
        }

            num *= 2;
    }

    System.out.println();
}

fredd [130]3 years ago
3 0

Answer:

while (numInsects < 100) {

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

        numInsects = numInsects * 2;

     }

     System.out.println();

Explanation:

Changed it to 100 to fit with your question

You might be interested in
Which of the following would most likely be the target audience for a product
inna [77]

Answer:

B

Explanation:

They are saturday morning cartoons. Saturday morning cartoons are meant towards an audience of young children.

3 0
3 years ago
Read 2 more answers
A manager suspects that one of his team members has been fraudulently accessing confidential and sensitive information and breac
Zigmanuir [339]

The technology that would be useful to look into the activities of the team member is the computer forensics

<h3>How to determine the technology?</h3>

Usually, when there is a case of data breach; the technology used to tackle the problem is the use of computer forensics.

This  is so because computer forensics involves identifying the storage of data on a computer system

Hence, the manager should make use of computer forensics

Read more about computer technology at:

brainly.com/question/1538272

#SPJ4

3 0
2 years ago
Read 2 more answers
Three materials needed to stream video video content
PIT_PIT [208]
Oh yeah yeah I don’t know ‍♂️ is
8 0
3 years ago
Read 2 more answers
What happens when you apply a theme to a form?
Ludmilka [50]

Answer:

it will be customizable, you can design it in a different style

Explanation:

4 0
3 years ago
Drag the tiles to the correct boxes to complete the pairs.
Mice21 [21]

Answer:

Operation open purpose

8 0
3 years ago
Read 2 more answers
Other questions:
  • Arpanet was developed by the united states so that there was a communication network that would survive a nuclear war. True or F
    11·1 answer
  • Which of the following resources is an example of a web-based application?
    15·1 answer
  • ?an ip address reservation is made by creating an association between an ip address and what type of client identifier?
    7·1 answer
  • What is the extension of Excel worksheet?
    8·1 answer
  • What were second generation languages that required detailed knowledge of the computer's hardware and a lot of spare time to wri
    11·1 answer
  • A presentation is widely used to present ______ and ______ effectively​
    12·1 answer
  • What in the world is this for and how do you use it
    8·2 answers
  • Please help 2 lazy to do! easy question
    10·1 answer
  • What is the difference between cyberbullying and bullying.
    5·2 answers
  • The _____ describes how data actually moves from an application on one computer to an application on another networked computer.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!