Question: Instructions : Code a for statement that increments from 1 through 10, but print only the even numbers using a fall-thru switch. You can catch
Instructions: Code a for statement that increments from 1 through 10, but print only the even numbers using a fall-thru switch. You can catch the odd numbers using the option in the switch that handles everything else. Name your program ForFallThruSwitch.java. Use Java Style Guide in line advancing and spacing.
Not printing odd numbers! 2 is an even number. Not printing odd numbers! 4 is an even number. Not printing odd numbers! 6 is an even number. Not printing odd numbers! 8 is an even number. Not printing odd numbers! 10 is an even number.
--------------------------
//class header
//Begin class scope.
//main method header
//Begin method scope.
//for header using i as loop-control variable
//Begin for scope.
//Code switch expression.
//Begin switch scope.
//First case.
//Next statement.
//Next statement.
//Next statement.
//Next statement.
//Print the number and that it is even, e.g., 2 is an even number.
//Next statement.
//Code option that handles the odd numbers.
//Print "Not printing odd numbers!
//Close switch scope.
//Close for scope.
//Exit program.
//End method scope.
//End class scope.
help with this code.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
