Ask your own question, for FREE!
Computer Science 20 Online
OpenStudy (anonymous):

int x = 0; for (int i = 1; i <= 100; i++) { x += 1; // Statement 1 if (i > N) continue; x += 1; // Statement 2 if (i > M) break; } a) If N = 30 and M = 50, then x = 131. b) If N = 70 and M = 90, then x = 182. c) If N = 20 and M = 30, then x = 62. d) If N = 50 and M = 75, then x = 150. God. I am flutterin confused!! Who can help me?!

OpenStudy (anonymous):

Why not try writing the program in an environment and try to run it? That way you can try a bunch of test cases and really learn what's going on in the program.

OpenStudy (anonymous):

public static void main(String[] args) { int x = 0; for(int i = 1;i <= 100;i++){ x+=1; //statement 1 if (i>30) continue; x+=1; //statement 2 if (i>50) break; System.out.println(x); } } I tried all the values for N and M but I didn't get the answer. Was my code incorrect?

OpenStudy (anonymous):

Yes actually it's incorrect, you should take "System.out.println(x)" out of the loop. Then try it again.

OpenStudy (anonymous):

public static void main(String[] args) { int x = 0; for(int i = 1;i <= 100;i++){ x+=1; //statement 1 if (i>30) continue; x+=1; //statement 2 if (i>50) break; } System.out.println(x); }

OpenStudy (anonymous):

Jesus! sofiasores, I love you baby!!!! Thank you sooooo much!!!!!!!

OpenStudy (anonymous):

:D

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!