if(weight <= 2)
{
charges=miles*1.10;
}
else if(weight > 2 && weight <= 6);
{
charges=miles*2.20;
}
else if(weight > 6 && weight <= 10);
{
charges=miles*3.37;
}
else if(weight > 10 && weight <= 20);
{
charges=miles*2.80;
}
这只是其中的一部分,但我一直收到以下错误消息:
ShippingAssign.java:32: 'else' without 'if'
else if(weight > 6 && weight <= 10);
^
ShippingAssign.java:36: 'else' without 'if'
else if(weight > 10 && weight <= 20);
^
2 errors
----jGRASP wedge: exit code for process is 1.
----jGRASP: operation complete.
任何关于我可能做错的想法?我觉得我明白了被问到的是什么,但显然我在某个地方犯了错误。
答案 0 :(得分:1)
每;
后删除else if
。
else if(weight > 2 && weight <= 6);
------------------^