0
Switch output
Why the result is 15.0?? public class Program { public static void main(String[] args) { float x=9,y=5; int z= (int) (x/y); switch (z){ case 1: x=x+2; case 2: x=x+3; case 3: x=x+1;} System.out.println (x); } }
5 ответов
+ 6
No break statements were present in the switch block. All cases were executed. The resulting value of x is 15.0.
+ 2
break;
is missing.
0
public class Program
{
public static void main(String[] args) {
int x=9,y=5;
int z;
z=(int)(x/y);
switch (z){
case 1:
x=x+2;
break;
case 2:
x=x+3;
break;
case 3:
x=x+1;
break;
}
System.out.println (x);
}
}
/*correction*/
0
oh yes, that simple. thank you
0
Yes