Chapter 5: Problem 9
Find and correct the error(s) in each of the following segments of code: a) for ( i = 100, i >= 1, i++ ) System.out.println( i ); b) The following code should print whether integer value is odd or even: switch ( value % 2 ) { case 0: System.out.println( "Even integer" ); case 1: System.out.println( "Odd integer" ); } c) The following code should output the odd integers from 19 to 1: for ( i = 19; i >= 1; i += 2 ) System.out.println( i ); d) The following code should output the even integers from 2 to 100: counter = 2; do { System.out.println( counter ); counter += 2; } While ( counter < 100 );
Short Answer
Step by step solution
Key Concepts
These are the key concepts you need to understand to accurately answer the question.