我的切换声明有问题,对不起,如果这是微不足道的,我很新!在切换语句中我收到错误:
令牌上的语法错误,而不是标签。
在我收到错误的每个案例中:
令牌上的语法错误"案例",断言预期
productNumber
和numberOfProduct
都是用户输入的int类型。 total
和currentTotal
的类型为double
。
Switch (productNumber) //problem occurs here, at the switch statement and at each case
{
case 1:
currentTotal = numberOfProduct * 2.98;
total += currentTotal;
break;
case 2:
currentTotal = numberOfProduct * 4.50;
total += currentTotal;
break;
case 3:
currentTotal = numberOfProduct * 9.98;
total += currentTotal;
break;
case 4://
currentTotal = numberOfProduct * 4.49;
total += currentTotal;
break;
case 5:
currentTotal = numberOfProduct * 6.87;
total += currentTotal;
break;
default:
System.out.println("The number entered is not a known product number. Known product numbers are 1, 2, 3, 4, and 5.");
--count;
}
答案 0 :(得分:0)
这是语法错误。 switch
需要小写。
答案 1 :(得分:0)
开关 - >切换?你可以尝试一下