Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 = 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
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