Question: 2.4 (6 points) Modify the following code (in BreakinWhile.java) in the while loop so that you do not need to use the break statement to
2.4 (6 points) Modify the following code (in BreakinWhile.java) in the while loop so that you do not need to use the "break" statement to get out of the while loop (hints use the combination logic of the two key variables). This program uses the while loop to sum all the numbers from zero onward. It breaks out of the while loop when the sum reaches >= 2000. You can download the program (BreakinWhile.java) from the eLearn dropbox and run it without any changes and show the following result: The while exit count number is 63 The sum (0...63) is 2016 1 */ public class BreakInwhile { public static void main(String[] args) { int sum = 0; int number = 0; I suppose you want to control the loop by using sum while (number = 2000) break; // replace the break with other logic > System.out.println("The while exit count number is " + number); System.out.println("The sum (..." + number +") is + sum): 1// end of main Wend of BreakdWhile class Ans: Submit the program that you have modified to remove the break statement and replaced it with codes (combination logic) that yields the same display results
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
