Question: Consider the following code fragment. Without changing the loop type, modify the code to prevent output when the input equals the sentinel value of zero.
Consider the following code fragment. Without changing the loop type, modify the code to prevent output when the input equals the sentinel value of zero.

Scanner stdIn = new Scanner(System.in); int x; do { x stdIn.nextInt (); System.out.println("negative " + (-X)); 3 while (x != 0);
Step by Step Solution
3.43 Rating (159 Votes )
There are 3 Steps involved in it
The code provided reads input from the user until the user enters a ... View full answer
Get step-by-step solutions from verified subject matter experts
