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
GaryK [48]
4 years ago
6

Write a while loop that prints userNum divided by 2 (integer division) until reaching 1. Follow each number by a space. Example

output for userNum = 40: 20 10 5 2 1 Note: These activities may test code with different test values. This activity will perform four tests, with userNum = 40, then with userNum = 2, then with userNum = 0, then with userNum = -1. See "How to Use zyBooks". Also note: If the submitted code has an infinite loop, the system will stop running the code after a few seconds, and report "Program end never reached." The system doesn't print the test case that caused the reported message.
Computers and Technology
1 answer:
jasenka [17]4 years ago
4 0

Answer:

public class Main

{

public static void main(String[] args) {

    int userNum = 40;

    while(userNum > 1){

        userNum /= 2;

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

    }

}

}

Explanation:

*The code is in Java.

Initialize the userNum

Create a while loop that iterates while userNum is greater than 1. Inside the loop, divide the userNum by 2 and set it as userNum (same as typing userNum = userNum / 2;). Print the userNum

Basically, this loop will iterate until userNum becomes 1. It will keep dividing the userNum by 2 and print this value.

For the values that are smaller than 1 or even for 1, the program outputs nothing (Since the value is not greater than 1, the loop will not be executed).

You might be interested in
Need ASAP
expeople1 [14]
The customer should consider buying the hard drive
3 0
3 years ago
The repair order is a legal document because?
svp [43]
D. It’s signed by the customer
4 0
3 years ago
Read 2 more answers
type the correct answer in the box. Spell all words correctly. Which element of the presentation software can you use to add cal
Anuta_ua [19.1K]

Answer:

The element of the presentation software that can be used to add callous and banners is SHAPES

Using the INSERT TAB, you can add callouts and banners to a slide.

Explanation:

If you want to add callouts and banners to a slide, the presentation software that can be used is PowerPoint.

The element that is used to add it is called shapes and can be found in the Insert Tab.

6 0
3 years ago
Implementing HTML best practices and writing code to match the original intentions of each element is known as __________ HTML.
erica [24]

Answer:

semantic

Explanation:

The description provided is describing the practice known as semantic HTML. This is basically code that provides both the user and the developer a description on what the code was originally supposed to do. For example, a method that calculates the total cost of a set of prices could be called calculateTotal(). By doing so you are describing the intention of the method clearly so that the individual using the method does not need to look at anything else to know what it does.

6 0
3 years ago
Which of the following most closely illustrates the correct format of the comparison in a conditional statement?
hoa [83]
Answer should be if (thisString = "What is your quest?")
6 0
3 years ago
Other questions:
  • All of the following statements correctly describe an advantage or disadvantage associated with the use of Monte Carlo Analysis
    9·1 answer
  • In which area of engineering does material selection play a vital role a design optimization b forensic engineering c mechanical
    6·1 answer
  • True or False?
    8·1 answer
  • i have a at&t router and a 1000mbs Ethernet cable connecting from that to my net gear r7000 that can push +1000mbs. the cabl
    14·1 answer
  • Web browsers are used to browse the world wide web.
    5·2 answers
  • Which of the following is not a primary environment in Autodesk Inventor? A. Parts B. Assemblies C. Animations D. Presentations
    10·1 answer
  • Took some photos today for photography class what do you think??
    13·2 answers
  • Why is it preferable to code web pages in HTML format?
    10·2 answers
  • A software program that allows you to create professional looking multimedia presentations. Question 1 options: Excel 365 Word 3
    6·1 answer
  • To improve readability and maintainability, you should declare ________ instead of using literal values such as 3.14159.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!