Related questions with answers
Question
Rewrite the programs TestBreak and TestContinue in Listings 4.12 and 4.13 without using break and continue.
Solution
VerifiedAnswered 6 months ago
Answered 6 months ago
Step 1
1 of 2public class TestBreak {
public static void main(String[] args)
{
int sum = 0;
int number = 0;
while (number < 20 && sum < 100)
{
number++;
sum += number;
}
System.out.println("The number is " + number);
System.out.println("The sum is " + sum);
}
}
public class TestContinue{
public static void main(String[] args)
{
int sum = 0;
int number = 0;
while (number < 20)
{
number++;
if (number != 10 && number != 11)
sum += number;
}
System.out.println("The number is " + number);
System.out.println("The sum is " + sum);
}
}
Create a free account to view solutions
By signing up, you accept Quizlet's Terms of Service and Privacy Policy
Create a free account to view solutions
By signing up, you accept Quizlet's Terms of Service and Privacy Policy
Recommended textbook solutions

Introduction to Java Programming, Brief
8th Edition•ISBN: 9780132130790 (1 more)Y. Daniel Liang500 solutions

Fundamentals of Database Systems
7th Edition•ISBN: 9780133970777Ramez Elmasri, Shamkant B. Navathe948 solutions

Introduction to Algorithms
3rd Edition•ISBN: 9780262033848Charles E. Leiserson, Clifford Stein, Ronald L. Rivest, Thomas H. Cormen872 solutions

Introduction to Algorithms
4th Edition•ISBN: 9780262046305Charles E. Leiserson, Clifford Stein, Ronald L. Rivest, Thomas H. Cormen945 solutions
More related questions
1/4
1/7