Answer:
Give me a break.
Example
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;
break;
case 'B':
discount = 0.1;
break;
case 'C':
discount = 0.2;
break;
default:
discount = 0.3;
}
System.out.println( "discount is: "
+ discount );
- The
integerExpressionis evaluated.- In this example, the expression is the variable,
code, which evaluates to the character 'B'.
- In this example, the expression is the variable,
- The case labels are inspected starting with the first.
- The first one that matches is
case 'B' - The corresponding
statementListstarts executing.- In this example, there is just one statment.
- The statement assigns 0.1 to
discount.
- The
breakstatement is encountered. - The statement after the
switchstatment is executed.- In this example, the
println()statement
- In this example, the
QUESTION 7:
If code is 'W' what is discount?