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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started