Hey this is my first post, I need some help with making a GUI Calculator, this is a extract from the code, I make the variables "num1" and "operator" in the PlusAction but when I try use them in the EqualsAction it doesn't reconise them and cant find them, PLEASE HELP
private void jBtnPlusActionPerformed(java.awt.event.ActionEvent evt) {
double num1 = Double.parseDouble (this.jTxtInput.getText());
String operator = "+";
this.jTxtInput.setText("");
}
private void jBtnEqualsActionPerformed(java.awt.event.ActionEve nt evt) {
Double num2 = Double.parseDouble(this.jTxtInput.getText());
Double ans=0.0;
if(operator.equals("+"))
{ ans = num1 + num2;
}