View the step-by-step solution to:

for (int i = 1; i <=n; i++) { if (i*k % 2 == 0) continue loop1; System.

Please help me rewrite the following code segment without using continue statement in Java


for(int k=0; k<n;k++){

loop2:

for (int i = 1; i <=n; i++) {

if (i*k % 2 == 0)

continue loop1;

System.out.println(i*k+" is not divisible by 2");

if (i*k % 5 == 0)

continue loop2;

System.out.println(i*k+" is not divisible by 5");

if (i*k % 11 == 0) {

System.out.println(i*k+" is divisible by 11");

break loop1;

}

}

}

Top Answer

Output:  1 is not divisible by 2 1 is not divisible by 5 3 is not divisible by 2 3 is... View the full answer

javaoutputwithoutcontinue.PNG

Sign up to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Ask a homework question - tutors are online