
![Write an expression that executes the loop while the user enters a number greater than or equal to 0.
Note: These activities may test code with different test values. This activity will perform three tests, with user input of 9, 5, 2, -1,
then with user input of 0, -17, then with user input of 0 1 0 -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 "Test
aborted."
367012.2549490.qx3zqy7
1 import java.util.Scanner;
2
3 public class NonNegativelooper {
public static void main (String [] args) {
4
5
Scanner scnr
new Scanner(System.in);
int userNum;
7
8
userNum
scnr.nextInt();
9.
while (* Your solution goes here
System.out.println("Body");
scnr.nextInt();
10
11
12
userNum
}
System.out.println("Done.");
}
13
14
15
16 }](https://content.bartleby.com/qna-images/question/c303f822-5e20-4d30-8920-178170554c96/cc2e6118-16a4-4bff-87c8-9b1306b206bc/hlapdw_thumbnail.png)

Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images

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.
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.
- -Prompts the user to enter an integer x. Assume without error checking the user enters a positive integer. -The program then will print all the odd integers between 1 and x that are a multiple of 3. Sample: Enter an integer x: 15 3 is a multiple of 3 9 is a multiple of 3 15 is a multiple of 3arrow_forwardConvert the following for loop condition into equivalent while loop condition:(How can you change the for loop into while loop?) for (a=1; a<=100; a++) { printf ("%d\n", a * a);arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





