某商场举行购物优惠活动如下表所示(x 代表购物款),请用switch语句编写程序,对输入的顾客购物款,计算出应付的款数。当 x<1600 时,不打折;当 1600<=x<2400 时打95折;当 2400<=x<3200 时打9折;当 3200<=x<6400 时打85折;当 x>=6400 时打8折。
查看答案
switch语句中,case后面的值必须是______。
A. 字符串
B. 字符变量
C. 数值
D. 常量值
以下程序段运行结果是________。int x = 0, a = 0, b = 0;switch (x) {case 0:a++;break;case 1:b++;break;}System.out.print("a=" + a + ",b=" + b);
A. a=0,b=0
B. a=1,b=0
C. a=0,b=1
D. a=1,b=1
以下代码输出的结果是________。int i=1;switch(i){case 0:System.out.print(0);break;case 1:System.out.print(1);case 2:System.out.print(2);default:System.out.print(3);}
A. 0
B. 123
C. 12
D. 1
若a和 b均是整型变量并已正确赋值,则下列switch 语句中正确的是________。
A. switch(a+b); { ...... }
B. switch( a+b*3.0 ){ ...... }
C. switch a { ...... }
D. switch( a%b) { ...... }