package standardcalculator;/**** @author BSK */public class calculator2 extends javax.swing.JFrame {    private String input=;//We have nothing to display on the screen,if we dont do this creates the problem of displaying the null.    private String firstOperand=0; //Standard firstOperand.    private String previousResult = ;//for storing the previous result.    private String operation=noOperation;//initialy noOperation.    /**    * Creates new form calculator2    */    public calculator2() {        initComponents();    }      private void commonAction(String inpt){        input += inpt;        displayscreen.setText(input);    }    private boolean isFirstOperand(){        return firstOperand.equals(0);    }    private void button1ActionPerformed(java.awt.event.ActionEvent evt) {                                                commonAction(1);    }                                       private void button2ActionPerformed(java.awt.event.ActionEvent evt) {                                            commonAction(2);}                                       private void button3ActionPerformed(java.awt.event.ActionEvent evt) {                                           commonAction(3);}                                       private void button4ActionPerformed(java.awt.event.ActionEvent evt) {                                           commonAction(4);}                                       private void button5ActionPerformed(java.awt.event.ActionEvent evt) {                                          commonAction(5);}                                       private void button6ActionPerformed(java.awt.event.ActionEvent evt) {                                            commonAction(6);}                                       private void button7ActionPerformed(java.awt.event.ActionEvent evt) {                                           commonAction(7);}                                       private void button8ActionPerformed(java.awt.event.ActionEvent evt) {                                           commonAction(8);}                                       private void button9ActionPerformed(java.awt.event.ActionEvent evt) {                                          commonAction(9);}                                       private void button0ActionPerformed(java.awt.event.ActionEvent evt) {                                           commonAction(0);}                                       private void buttonDotActionPerformed(java.awt.event.ActionEvent evt) {                                              commonAction(.);}                                         private void butMulActionPerformed(java.awt.event.ActionEvent evt) {                                           operation = multiply;    double result;    input = displayscreen.getText();    if (input.equals()){    }    else if ( isFirstOperand()){        firstOperand = input;        previousResult = firstOperand;        displayscreen.setText();    }    else{        result = Double.parseDouble(previousResult);        result *= Double.parseDouble(input);        displayscreen.setText(result+);        previousResult = result+;        firstOperand = 0;    }    input=; //As we have stored the input now we need new input ,i.e,the new variable.}                                      private void butDivideActionPerformed(java.awt.event.ActionEvent evt) {                                              operation = divide;    double result;    input = displayscreen.getText();    if ( input.equals()){    }    else if ( isFirstOperand()){        firstOperand = input;        previousResult=firstOperand;        displayscreen.setText();    }    else{        result = Double.parseDouble(previousResult);        result /= Double.parseDouble(input);        displayscreen.setText(result+);        previousResult = result+;        firstOperand = 0;    }    input=; //As we have stored the input now we need new input ,i.e,the new variable.}                                         private void butMinusActionPerformed(java.awt.event.ActionEvent evt) {                                             operation = minus;    input = displayscreen.getText();    double result;    if ( input.equals()){    }    else if ( isFirstOperand()){        firstOperand = input;        previousResult=firstOperand;        displayscreen.setText();    }    else{            result = Double.parseDouble(previousResult);            result -= Double.parseDouble(input);            displayscreen.setText(result+);            previousResult = result+;            firstOperand = 0;        }    input=; //As we have stored the input now we need new input ,i.e,the new variable.}                                        private void butAddActionPerformed(java.awt.event.ActionEvent evt) {                                           operation = add;    input = displayscreen.getText();    double result;    if ( input.equals()){    }    else if ( isFirstOperand()){        firstOperand = input;        previousResult=firstOperand;        displayscreen.setText();    }    else{            result = Double.parseDouble(previousResult);            result += Double.parseDouble(input);            displayscreen.setText(result+);            previousResult = result+;            firstOperand = 0;        }    input=; //As we have stored the input now we need new input ,i.e,the new variable.}                                      private void butEqualsActionPerformed(java.awt.event.ActionEvent evt) {                                              double result;       if ( input.equals()){    }    else{          switch(operation){            case add:                result = Double.parseDouble(previousResult) + Double.parseDouble(input);                displayscreen.setText(result+);                break;            case minus:                result = Double.parseDouble(previousResult) - Double.parseDouble(input);                displayscreen.setText(result+);                firstOperand=0;                break;            case multiply:                result = Double.parseDouble(previousResult) * Double.parseDouble(input);                displayscreen.setText(result+);                firstOperand=0;                break;            case divide:                result = Double.parseDouble(previousResult) / Double.parseDouble(input);                displayscreen.setText(result+);                firstOperand=0;                break;            case modulus:                result = Double.parseDouble(previousResult) % Double.parseDouble(input);                displayscreen.setText(result+);                firstOperand=0;                break;            case reciprocal:                result = 1/Double.parseDouble(previousResult);                displayscreen.setText(result+);                firstOperand=0;                break;            case root:                result = Math.sqrt(Double.parseDouble(previousResult));                displayscreen.setText(result+);                firstOperand=0;                 break;              case noOperation:                break;       }    }}                                         private void displayscreenActionPerformed(java.awt.event.ActionEvent evt) {                                                  //input=displayscreen.getText();}                                             /** * @param args the command line arguments */public static void main(String args[]) {     java.awt.EventQueue.invokeLater(new Runnable() {        public void run() {            new calculator2().setVisible(true);        }    });}// Variables declaration - do not modify                     private javax.swing.JButton butAdd;private javax.swing.JButton butDivide;private javax.swing.JButton butEquals;private javax.swing.JButton butMinus;private javax.swing.JButton butModulus;private javax.swing.JButton butMul;private javax.swing.JButton butReciprocal;private javax.swing.JButton button0;private javax.swing.JButton button1;private javax.swing.JButton button2;private javax.swing.JButton button3;private javax.swing.JButton button4;private javax.swing.JButton button5;private javax.swing.JButton button6;private javax.swing.JButton button7;private javax.swing.JButton button8;private javax.swing.JButton button9;private javax.swing.JButton buttonDot;private javax.swing.JTextField displayscreen;// End of variables declaration}Here are the conditions that I have covered:The multiply button is pressed again and again.If we have not input and pressing the multiply button.Repeatedly multiply without pressing the = key. Note: Input is given and shown in textField each time user enter a button, I did not show the code for that.My question is about the readability of the code, and my applied algorithm. Is it efficient?Please keep patience as I am new to Java and learning to design the algorithm, and please provide me some references about how to design an efficient algorithm.
Is this code for a calculator efficient?
java;beginner;algorithm;calculator