// Rewriting code (part d) public class RewritingCode_d { public static void main(String[] args) { System.out.println("====== ORIGINAL DO LOOP ======="); boolean done=false; int k=20; do { while(true) { k--; if(k==0) {done=true; break;} if(k%2==0) { break; } } System.out.println(k); }while(!done); System.out.println("====== NESTED FOR LOOPS ======="); done=false; for(k=20; !done;) { for(;;) { k--; if(k==0) {done=true; break;} if(k%2==0) { break; } } System.out.println(k); } /* Compile either this or the original code //System.out.println("====== REWRITTEN AS FOR LOOP (v. 1) ======="); do { }while(true); */ } }