Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started