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
Write a method that determines the total number of chars in each string of an array.
Serjik [45]
The total number of chars in each string is basically the size of each string.

Using JAVA:

        String[] arr = {"hello", "my", "name", "is", "Felicia"};                int count = 0;        for(int i = 0; i < arr.length; i++) {            count = count + arr[i].length();            System.out.println("Characters in " + arr[i] + ": " + count);        }

Output: 
<span>Characters in hello: 5
Characters in my: 7
Characters in name: 11
Characters in is: 13
Characters in Felicia: 20</span>


8 0
3 years ago
How many programs can you run in Windows simultaneously
jenyasd209 [6]

Answer:

We can run multiple programs on windows simultaneously. There is no specific limit to run the programs.

Explanation:

We can run multiple application at the same time without having any limit.

<u>Microprocessor</u>

Microprocessor is the essential part of the computer. It is used to perform arithmetic and logic operations. The microprocessors are multitasking, its means that they can perform multiple tasks at the same time. It gives breaks all tasks into small portions and gives equal time to all process portions equally.

<u>Windows</u>

There is scheduler in windows that schedule all tasks for processing on priority basis. This will help computer to perform multiple task at the same time.

As computers have microprocessors that are used to process multiple application at the same time.

7 0
4 years ago
Which type of document should Omar print?
Zinaida [17]

Well it depends on the topic he is doing. if it is a list then a plain doc with a list of numbers. if he is writing a letter then he should use the letter template.

7 0
3 years ago
Read 2 more answers
25 POINTS!!!!!!!!!!!!!
siniylev [52]

Answer:

im pretty sure its digital footprint

Explanation:

3 0
3 years ago
You manage the DNS servers for the eastsim domain. You have a domain controller named DNS1 running Windows Server 2016 that hold
Ierofanga [76]

Answer:

..

Explanation:

...

3 0
3 years ago
Other questions:
  • Imagine you are writing a personal fitness program that stores the user's age, gender, height (in feet or meters), and weight (t
    10·1 answer
  • Define a method named roleOf that takes the name of an actor as an argument and returns that actor's role. If the actor is not i
    11·1 answer
  • Describe the difference between public and private IPv4 addresses. If a network is using private IP addresses, how can the compu
    13·1 answer
  • What are some of the good effects of social media
    7·1 answer
  • You notice your glove is torn; what should you do
    14·2 answers
  • Write a function findWithinThreshold that identifies the elements of a given array that are inside a threshold value. Takes the
    13·1 answer
  • A Variable can only hold numbers<br><br> True<br><br> False
    15·2 answers
  • With what software tool can you see the applications that are currently runni
    13·1 answer
  • Trebuie sa scrii niște instrucțiuni în JavaScript care adaugă în DIV lungimea HTML-ului din interiorul tag-ului cu ID​
    14·1 answer
  • What is the difference between packaged and tailored software ​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!