answer.
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]
2 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]2 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
Select the correct answer. Andy wants to become a multimedia producer. Which degree can help him achieve this goal? A. bachelor’
tatuchka [14]

Answer:

C. bachelor’s degree in filmmaking

Explanation:

Because Andy wants to become a multimedia producer, the degree that would best help him achieve his goal is a bachelor's degree in filmmaking.

Multimedia has to do with both audio, video and graphics or animations because it encompasses multiple media files.

Filmmaking has to do with the various forms of making and producing films. Filmmaking has to do with multiple media (multimedia) and it would help him achieve his goal.

7 0
1 year ago
Problem statement: Using loop, write a program that will ask the user to enter a character for left or right. Then, the user wil
zvonat [6]
Define variables
left is l
right is r

Ask input
left or right

Ask input value

Equate l or r to the input value

Show ladder with steps equal to input value and in the side of input variable
7 0
1 year ago
Shirley was unsure about what career to go into. Her high school counselor suggested a personal assessment to point out Shirley’
Alex73 [517]
<span>I think that she would be well suited in going into law enforcement or fire fighting. Since she loves to stay active and is cool under pressure, both of those jobs would be very well suited for her personality. Those 2 jobs demand to stay cool into delicate situations. Also, she would be able to come in to help people in need.</span>
4 0
1 year ago
Read 2 more answers
1. Accessing calendars, contact information, emails, files and folders, instant messages, presentation, and task lists over the
Veseljchak [2.6K]
1. Cloud Computing
2. Web Conferencing
3. Ribbon
4. PowerPoint
5. Sadie should share the document in One Drive and give her sister permission to edit the document
6. The design and arrangement of items for efficiency and safety
6 0
1 year ago
Instead of sending an entire file in one big chunk across the​ Internet, __________ is used which dices the file up into little
azamat

Answer:

TCP/IP

Explanation:

TCP/IP which stands for Transmission Control Protocol and Internet Protocol are network protocols which divide your message into smaller chunks or fragments known as network packets and sends them out onto the Internet. When the chunks arrive at the intended destination, TCP/IP on the receiving end reassembles the network packets into the original message.

TCP/IP are the main protocols used for sending data over the internet.

7 0
1 year ago
Other questions:
  • Which of these is an advantage of using the Clipboard task pane? A. You are able to apply OLE easily. B. There are more paste op
    15·2 answers
  • The __________ of a desktop computer is the case that houses the computerâs critical parts, such as the processing and storage d
    5·1 answer
  • An mp3 takes up about 16 kilobytes of memory per second of music. if you owned a one terabyte hard drive and filled it with only
    15·1 answer
  • An electronics store purchased a CD player at a wholesale price of $60 and then sold it at a 40 percent discount off the origina
    13·1 answer
  • Define a function PyramidVolume with double parameters baseLength, baseWidth, and pyramidHeight, that returns as a double the vo
    7·2 answers
  • Apart from the challenges of heterogeneity, business and social change and trust and security, identify other problems and chall
    9·1 answer
  • Which would be the most efficient way to store files on your computer?
    13·2 answers
  • Assume you have a project with seven activities labeled A-G (following). Derive the earliest completion time (or early finish-EF
    15·1 answer
  • A credit card company receives numerous phone calls throughout the day from customers reporting fraud and billing disputes. Most
    10·1 answer
  • Write a function named shout. The function should accept a string argument and display it in uppercase with an exclamation mark
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!