-5

I am currently trying to write a programm that gets two variables and calculates them. The problem I am facing is that Java Editor shows me "cannot find symbol".

public class neupqinputerror extends JFrame {


    public double haelfteP(double p){

        return p/2.0;
    }
    public double quadratVonHaelfteP(double haelfteP){
        return Math.pow (haelfteP, 2);
    }

    public double wurzelTeil(double quadratVonHaelfteP,double q){
        return quadratVonHaelfteP - q;
    }

    public double wurzelFertig(double wurzelTeil){
        return Math.sqrt(wurzelTeil);
    }

    public double pqFormelPlus(){
        return haelfteP             + wurzelFertig; 
    }

    public double pqFormelMinus(){
        return haelfteP - wurzelFertig; 
    }

    public void jButton1_ActionPerformed(ActionEvent evt) {
        nf_x1.setDouble(pqFormelPlus());
        nf_x2.setDouble(pqFormelMinus());
    }

    public void main(String[] args) {
        double haelfteP;
        double p;
        double q;
        double x1;
        double x2;
        double halbP;
        String qEingabe;
        String pEingabe;

        pEingabe = tf_p.getText();
        p = Double.valueOf(pEingabe);
        qEingabe = tf_q.getText();
        q = Double.valueOf(qEingabe); 
    }

}

and that are the mistakes I get.

neupqinputerror.java:128:12: error: cannot find symbol
return haelfteP             + wurzelFertig; 
       ^
symbol:   variable haelfteP
location: class neupqinputerror
neupqinputerror.java:128:35: error: cannot find symbol
return haelfteP             + wurzelFertig; 
                              ^
symbol:   variable wurzelFertig
location: class neupqinputerror
neupqinputerror.java:132:12: error: cannot find symbol
return haelfteP - wurzelFertig; 
       ^
symbol:   variable haelfteP
location: class neupqinputerror
neupqinputerror.java:132:23: error: cannot find symbol
return haelfteP - wurzelFertig; 
                  ^
symbol:   variable wurzelFertig
location: class neupqinputerror

How can I solve those problems?

Note: tf_p and tf_q are textfields of the gui

thanks

innoSPG
  • 4,588
  • 1
  • 29
  • 42
Helena Ann
  • 21
  • 1
  • 6
  • 1
    See [What does a “Cannot find symbol” compilation error mean?](http://stackoverflow.com/questions/25706216/what-does-a-cannot-find-symbol-compilation-error-mean?rq=1) – Jesper Jun 27 '16 at 11:34

3 Answers3

2

you dont have variable wurzelFertig.

wurzelFertig is a method, you should invoke it calling: wurzelFertig(double wurzelTeil)

Daniel Stradowski
  • 3,466
  • 1
  • 12
  • 21
  • if i do this public double wurzelTeil(double quadratVonHaelfteP,double q){ return quadratVonHaelfteP(double haelfteP) - q; } this error occurs: error: '.class' expected – Helena Ann Jun 27 '16 at 11:40
2

In java, methods are to be called with a parantheses always. Like in your case, instead of haelfteP, call haelfteP()

In the case of wurzelFertig method, there is a need of a parameter as well. So pass the parameter inside the parantheses, like this wurzelFertig(wurzelFertig)

aksappy
  • 3,400
  • 3
  • 23
  • 49
0

wurzelFertig was never declared anywhere

Hans
  • 2,354
  • 3
  • 25
  • 35