No
We will get to those other rules shortly. Here is the previous example, with more explanation:
double discount;
char code = 'B' ; // Usually the value for code would come from data
// or from user interaction
switch ( code )
{
case 'A':
discount = 0.0;
break;
case 'B':
discount = 0.1;
break;
case 'C':
discount = 0.2;
break;
default:
discount = 0.3;
}
System.out.println( "discount is: " + discount );
expression is evaluated.
code,
which evaluates to the character 'B'.case 'B'statementList after case 'B' starts executing.
discount.break statement is encountered which ends the statementList.switch statement is executed.
println() statementIf code is 'W' what is discount?