QUESTION

Text
Image


CHALIENGE ACTIVITY 4.2.2: Basic while loop with user input. 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 $010-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. inport Java.ut11.Scanner: public class NonlegativeLooper if public statie vold main (5tring [] args) [ Scanner scnr - new Scanner(System, in); int userflun: userNun $=$ scnr, nextInt ()$;$ while $\left(y^{*}\right.$. Your solution goes here $\left.\&\right)$ ( System. out.printin( ("Body") userkun = scnr, nextInt(); Systen.out.printin("Done, - );


CHALENGE ACTIVITY 4.2.3: Basic while loop expression. 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$ : 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. 1 import java.util. Scanner; public class DivideByTwoLoop ( ) public static vold nain (String [] args) \{ Scanner scnr = new Scanner(System. in); int userNum; userNum = senr. nextInt(); $f$ Your solution goes here $*$ System.out.print $\ln (* *)$

Feodback? CHALIFNGE ACTIVITY 4.3.2: Bidding example. Write an expression that continues to bid until the user enters ' $n$ ' $\frac{1}{2}$ import java.uti1.Scanner; 3 public class Autobidder public static void main (String [] args) \& Scanner scar = new Scanner(System. in); char keepoing: int nextbid; nexteid $=0$ keepGoing $=$ " $y$ ' while ( $/$ Your solution goes here */) \& nextBid $=$ nexteid +3 ; System. out.printin("I'11 bid $\mathbf{s}^{*}+$ nextBid + "I"); System, out, print ("Cont inue bidding? $(y / n) "$ "); keeplioing = scnr, next (), charAt(a); ) System, out, printan(-u); Run

OHALLENGE ACTIVITY 4.3.3: While loop: Insect growth. Given positive integer numlnsects, write a while loop that prints that number doubled without reaching 200 . Follow each number with a space. After the loop, print a newline. Ex: If numlnsects $=16$, print: 163264128 Import java.util.Scanner; public class Insectgrowth $(8)$ public static void main (String [] args) \& Scanner scar = new Scanner(Systea. in); int numinsects; numInsects $=$ senr. nextInt ()$; / /$ Must be $>-1$ $f=$ Your solution goes here *I Run

Public Answer

MGKZQP The First Answerer