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]
2 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]2 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]2 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
What is A wage paid based on the ability to sell a product or service is (a) _____.
Fantom [35]
The answer is commissioned
5 0
3 years ago
The "fathers of the internet" are vinton cerf and ________.
Harrizon [31]
Robert E Kahn I hope this helps
8 0
3 years ago
What is Converting digital data and see information to display screen can use to create an image?
aksik [14]

Answer:

Most displays in current use employ cathode ray tube ( CRT ) technology similar to that used in most television sets. The CRT technology requires a certain distance from the beam projection device to the screen in order to function.

4 0
2 years ago
Anyone can help me with this?
dybincka [34]

Answer:

/*

 Find Largest and Smallest Number in an Array Example

 This Java Example shows how to find largest and smallest number in an  

 array.

*/

public class FindLargestSmallestNumber {

 

public static void main(String[] args) {

 

//array of 10 numbers

int numbers[] = new int[]{32,43,53,54,32,65,63,98,43,23};

 

//assign first element of an array to largest and smallest

int smallest = numbers[0];

int largetst = numbers[0];

 

for(int i=1; i< numbers.length; i++)

{

if(numbers[i] > largetst)

largetst = numbers[i];

else if (numbers[i] < smallest)

smallest = numbers[i];

 

}

 

System.out.println("Largest Number is : " + largetst);

System.out.println("Smallest Number is : " + smallest);

}

}

 

/*

Output of this program would be

Largest Number is : 98

Smallest Number is : 23

*/

Explanation:

5 0
2 years ago
TQ Sustainability &amp; Technology
harkovskaia [24]

A way to make the metro system more sustainable is to use machine learning so as to optimize the frequency of train routes  using passenger load.

<h3>What is a sustainable transport system?</h3>

This sustainable transport system is known to be a kind of system that aids the basic access and growth needs of the society to be met rightly and safely.

This also should be meant in a way that is consistent with human and ecosystem health, and boast equity in all successive generations.

Other methods are the use of Cooling System to lower temperature and non waste of Energy and also lower the Noise Levels.

learn more about Sustainability from

brainly.com/question/25032305

4 0
2 years ago
Other questions:
  • Classify the given items as belonging to the public domain or protected by copyright law.
    6·2 answers
  • Why is color theory important
    6·2 answers
  • Josh wants to convey his best wishes to johnathin for a meeting schedualed later diring the day. Which business documented would
    7·1 answer
  • Oxnard Casualty wants to ensure that their e-mail server has 99.98 percent reliability. They will use several independent server
    14·1 answer
  • A message M is encapsulated by the TCP, IP and Ethernet protocols in that order as it travels down a protocol stack. What does t
    5·1 answer
  • What does the following code segment do?
    13·1 answer
  • Explain why there are fundamental ideas of software engineering that apply to all types of software systems.
    7·1 answer
  • These are used to divide the document into sections. *
    5·1 answer
  • What are the different types of application architecture
    5·1 answer
  • Maria needs to use a requirement-gathering method that will help her provide a set of questions to the client. Which method shou
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!