1. What is the difference between a while loop and a do..while loop?
2. Every switch statement can be rewritten as a series of nested if statements. Is the reverse true? Give an example of a set of nested loops that could not be implemented as a switch statement?
3. State what output, if any, results in each of the following code segments, use a trace table to show the execution of the loops:
int i=5;
int sum = 0;
while (i>=0){
sum = sum + i 2; i--;
System.out.println(sum);
b. int x, y;
do
System.out.println(x , " + y); x=x+1;
while (x
SycstefV.oluntt.pirin't((ii'5-5)--V(*** ");
}
System.out.println();
fc.(1 = i; <= 3; I-'){ System.out.print("*");
System.out.println();
4. Rewrite the while loop in question 3a as a for loop AND rewrite the for loop in question 3c as a while loop