Question: Consider the segment of Java program below: int s 4, n = 3; boolean b; while (n = 5) { n++; s += n; b

 Consider the segment of Java program below: int s 4, n

Consider the segment of Java program below: int s 4, n = 3; boolean b; while (n = 5) { n++; s += n; b = (n X 5 = 0); System.out.println("n if (s > 10) { System.out.println("S break; } } +n +" and b = " +b); "+s); a) Jejak segmen program di atas dengan menunjukkan nilai-nilai bagi setiap pemboleh ubah dan tuliskan output segmen program ini Trace the program segment above by showing the values for each variable and write the program segment output [4M] b) Tuliskan semula segmen program di dalam soalan 1a) dengan menggunakan gegelung for bagi menggantikan gegelung while. Rewrite the program segment in question 1a) using for loop to replace while loop. [3M] c) Tukar pernyataan if...else berikut kepada pernyataan switch: Convert the following if...else code to switch code: if (a == 1) X += 5; else if (a 2) X += 6; else if (a 3) X += 7; else if (a 4) x += 8; else System.out.println("wrong input"); == == [3M]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!