如果陈述逻辑不起作用

use*_*212 0 java if-statement

所以我有这两个类叫做装运和保险,一个计算运费的价格,另一个加上保险.出货逻辑工作正常,但由于某种原因保险类中的if语句不起作用,我不知道发生了什么.保险费用的输出总是2.45.它为什么这样做?

装运等级:

  package theshipment;

  public class Shipment extends Main {
      protected double weight = Double.parseDouble(savedArgs[1]);
      protected double shippingCost;
      protected double methodCost;
      protected String method = savedArgs[2];

      public void calculateShippingCost(){

        if (weight<=10||weight>=1){
            if (method.equalsIgnoreCase("T"))
                methodCost = weight * 3.00;
            else if (method.equalsIgnoreCase("A"))
                methodCost = weight * 4.00;
            else if (method.equalsIgnoreCase("M"))
                methodCost = weight * 2.00;
            else{}
        }else if (weight<=20||weight>=10.1){
            if (method.equalsIgnoreCase("T"))
                methodCost = weight * 2.45;
            else if (method.equalsIgnoreCase("A"))
                methodCost = weight * 3.00;
            else if (method.equalsIgnoreCase("M"))
                methodCost = weight * 1.75;
            else{}
        }else if (weight>20){
            if (method.equalsIgnoreCase("T"))
                methodCost = weight * 1.95;
            else if (method.equalsIgnoreCase("A"))
                methodCost = weight * 2.50;
            else if (method.equalsIgnoreCase("M"))
                methodCost = weight * 1.55;
            else{}
        }else{}

    }
}
Run Code Online (Sandbox Code Playgroud)

和保险类:

package theshipment;

public class Insurance extends Shipment{
    private void calculateInsurance(){  
        if (methodCost<=10.0||methodCost>=0.0)
            shippingCost = methodCost + 2.45;
        else if(methodCost<=30.0||methodCost>=10.1)
            shippingCost = methodCost + 3.95;
        else if(methodCost>=30.01)
            shippingCost = methodCost + 5.55;
        else{}       
    }

    public void run(){
        calculateShippingCost();
        calculateInsurance();
    }

    public String displayOrder(){
        return ("Method cost: " + methodCost + " " + "Insurance cost: " + 
               (shippingCost-methodCost) + " Total shipping cost: " + shippingCost);
    }

}
Run Code Online (Sandbox Code Playgroud)

use*_*383 10

methodCost<=10.0||methodCost>=0.0这意味着当methodCost大于0 小于10时,它将是真的,

我相信你想要的范围不是所有数字都改变它 methodCost<=10.0 && methodCost>=0.0