write a program using switch case on transportation in java
Answers
Answer:
The switch statement evaluates the expression (mostly variable ) and compares it with values (can be expressions) of each case label. Now, if the value matches a certain case label, then all the statements of the matching case label are executed. For example, if the variable/expression is equal to value2
Explanation:
A general syntax of how switch-case is implemented in a 'C' program is as follows: switch( expression ) { case value-1: Block-1; Break; case value-2: Block-2; Break; case value-n: Block-n; Break; default: Block-1; Break; } Statement-x; The expression can be integer expression or a character expression.
hope this helps you
The switch statement evaluates the expression (mostly variable ) and compares it with values (can be expressions) of each case label. Now, if the value matches a certain case label, then all the statements of the matching case label are executed. For example, if the variable/expression is equal to value2 .