A good answer might be:

Give me a break.


We will get to those other rules shortly. Here is the previous example, with more explanation:

double discount;
// Usually code would be read in
char   code = 'B' ;   

switch ( code )
  case 'A':
    discount = 0.0;

  case 'B':
    discount = 0.1;

  case 'C':
    discount = 0.2;

    discount = 0.3;

System.out.println( "discount is: " 
  + discount );
  1. The integerExpression is evaluated.
    • In this example, the expression is the variable, code, which evaluates to the character 'B'.

  2. The case labels are inspected starting with the first.

  3. The first one that matches is case 'B'

  4. The corresponding statementList starts executing.
    • In this example, there is just one statment.
    • The statement assigns 0.1 to discount
    • .

  5. The break statement is encountered.

  6. The statement after the switch statment is executed.
    • In this example, the println() statement


If code is 'W' what is discount?