// do-while -tsükli kasutamine lihtsa abiinfosüsteemi loomiseks. class Menu { public static void main(String args[]) throws java.io.IOException { // Juhuks kui sisestamisel tekib "erakordne" situatsioon char choice; do { System.out.println("Info käsust:"); System.out.println(" 1. if"); System.out.println(" 2. switch"); System.out.println(" 3. while"); System.out.println(" 4. do-while"); System.out.println(" 5. for\n"); System.out.println("Vali :"); choice = (char) System.in.read(); // Ootame kuni sisestatakse klahvistikult üks sümbol } while( choice < '1' || choice > '5'); // Vale sisestuse korral kordame ! System.out.println("\n"); switch(choice) { case '1': System.out.println(" if:\n"); System.out.println("if(tingimus) operaator1;"); System.out.println("else operaator2;"); break; case '2': System.out.println(" switch:\n"); System.out.println("switch(avaldis) {"); System.out.println(" case konstant:"); System.out.println(" operaatorijada"); System.out.println(" break;"); System.out.println(" // ..."); System.out.println("}"); break; case '3': System.out.println(" while:\n"); System.out.println("while(tingimus) operaator;"); break; case '4': System.out.println(" do-while:\n"); System.out.println("do {"); System.out.println(" operaator(id);"); System.out.println("} while (tingimus);"); break; case '5': System.out.println(" for:\n"); System.out.print("for(initsialiseerimine; tingimus; iteratsioon)"); System.out.println(" operaator;"); break; } System.out.println(); } }