// WhileoddKL.java Copyright (c) 2006 Kari Laitinen // http://www.naturalprogramming.com // 2006-02-12 File created. // 2006-02-12 Last modification. // Solution to Exercise 6-6. class WhileoddKL { public static void main( String[] not_in_use ) { int number_to_print = 0 ; System.out.print( "\n Odd numbers from 0 to 20 are the following:\n\n ") ; while ( number_to_print <= 20 ) { if ( ( number_to_print % 2 ) == 1 ) { System.out.print( " " + number_to_print ) ; } number_to_print ++ ; } System.out.print( "\n\n Another solution to the problem ... \n\n ") ; number_to_print = 1 ; while ( number_to_print <= 20 ) { System.out.print( " " + number_to_print ) ; number_to_print = number_to_print + 2 ; ; } } }