vendredi 22 septembre 2017

Why my if statement doesnt work at latest line?

Im newbie in java. I would like to know why my latest if doesnt work at x<=a || x>=c. This is my code:

private void HitungActionPerformed(java.awt.event.ActionEvent evt) {                                       
            // TODO add your handling code here:
            Double a = Double.parseDouble(A.getText());
            Double c = Double.parseDouble(C.getText());
            Double x = Double.parseDouble(X.getText());
            Double b1 = (((c+a)/2)-a)/2;
            Double b2 = (c-((c+a)/2))/2;
            Double nilaiTengah = (c+a)/2;
            Double y1 = 1/(1+(Math.pow((x-nilaiTengah)/b2, 2)));
            Double y2 = 1/(1+(Math.pow((nilaiTengah-x)/b1, 2)));

            if(x > nilaiTengah) {Y.setText(String.valueOf(y1)); B.setText(String.valueOf(b2));}
            else if(x < nilaiTengah) {Y.setText(String.valueOf(y2)); B.setText(String.valueOf(b1));}
            else  if (Objects.equals(nilaiTengah, x)){Y.setText("1");B.setText("");}
            else  if (x<=a || x>=c) {Y.setText("0");B.setText("");}        
        }    

Aucun commentaire:

Enregistrer un commentaire