Find the error in each of the following code segments, and explain how to correct it: a) i = 1 ; while (i 10 ); ++i; } b) for (k = 0.1 ; k != 1.0 ; k += 0.1 ) System.out.println(k); c) switch (n) {...

Find the error in each of the following code segments, and explain how to correct it:

a) i =
1;



while
(i
10);


++i;


}


b)
for
(k =
0.1; k !=
1.0; k +=
0.1)


System.out.println(k);


c)
switch
(n)


{



case

1:


System.out.println("The number is 1");



case

2:


System.out.println("The number is 2");



break;



default:


System.out.println("The number is not 1 or 2");



break;


}


d) The following code should print the values 1 to 10:


n =
1;



while
(n
10)


System.out.println(n++);




May 19, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here