
Untitled
By: a guest on
Jul 20th, 2012 | syntax:
None | size: 0.60 KB | hits: 12 | expires: Never
why this SCJP program gives output 21 but I am getting 20?
public class Stepper
{
enum Roman {I,V,X,L,C,M}
public static void main(String... args)
{
int x=7;
int z=2;
Roman r = Roman.X;
do
{
switch(r)
{
case C : r = Roman.L;break;
case X : r = Roman.C;
case L : if(r.ordinal()>2)
{
z += 5;//7,13,19
}
case M : x++;//8,9,10
}
z++;//8,14,20
}
while (x<10);
System.out.println(z); //
}
}
case C : r = Roman.L;
break;