Question: undefined 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
undefined
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 /* */ public class BreakInWhile { public static void main(String[] args) { int sum = 0; int number = 0; // 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)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
