运费收费计划错误

时间:2014-02-01 19:19:59

标签: java compiler-errors jgrasp

 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.

任何关于我可能做错的想法?我觉得我明白了被问到的是什么,但显然我在某个地方犯了错误。

1 个答案:

答案 0 :(得分:1)

;后删除else if

else if(weight > 2 && weight <= 6);
                ------------------^