title: Trying to make a functional calculator in java, I can't figure out where I'm going wrong
body: <p>I'd like to start off saying that I'm still really new to java, but I promise this is not a troll post.  So I have to make a functional four function calculator for school.  It's really basic but for some reason I can't get it to work properly.  I was given the following as example code, my teacher told us to infer the rest.  </p>
  
  <pre><code>import java.awt.*;
  import java.awt.event.*;
  import javax.swing.*;
  
  public class Calculator implements ActionListener 
  {
  
    JFrame f1;
    JTextField display;
    JButton b1,b2,addb,equalsb,clearb;
    JPanel p1;
    String value,operation; 
    double secondnum, total;
  
  
     public Calculator()
    {
      value = "";
      total = 0.0;
      secondnum = 0.0;
  
      f1 = new JFrame("Calculator");
      f1.setSize(400,100);
      Container c1 =  f1.getContentPane();
  
      display = new JTextField(15);
      b1 = new JButton("1");
      b1.addActionListener(this);                  // adds a Listener for Button b1
  
      b2 = new JButton("2");
      b2.addActionListener(this); 
  
      addb = new JButton("+");
      addb.addActionListener(this); 
  
      equalsb = new JButton("=");
      equalsb.addActionListener(this);
  
      clearb = new JButton("C");
      clearb.addActionListener(this);
  
      p1 = new JPanel();
  
      p1.add(display);
      p1.add(b1);
      p1.add(b2);
      p1.add(addb);
      p1.add(equalsb);
      p1.add(clearb);
      c1.add(p1);
  
      f1.show();
  
     }
  
  
  
      public void actionPerformed(ActionEvent event)        
        {                                                    
         if (event.getSource()== b1)      
            value = value + "1";
  
        if (event.getSource() == b2)     
             value = value + "2";
  
        if (event.getSource() == clearb)
           {
             total = 0.0; 
             secondnum = 0.0;
             value = "";
           }
  
  
        if (event.getSource() == addb)
          {
             total = Double.parseDouble(value);
             operation = "add";
             value = "";
          }
  
        if (event.getSource() == equalsb)
          {
            secondnum = Double.parseDouble(value);   
  
            if(operation.equals("add"))
                total = total + secondnum;
  
            value = ""+ total;            //value becomes what the total is to be diplays  
          }   
  
  
     display.setText(value);
      }
    }
  </code></pre>
  
  <p>This works, so from it I created the following.  I'm pretty sure i'm going wrong in the function keys, but I have no clue where I messed up.  </p>
  
  <pre><code>import java.awt.*;
  import javax.swing.*;
  import java.awt.event.*;
  
  public class Calculator implements ActionListener
  {
  JFrame f;
  Container c; 
  JPanel p; 
  JTextField display; 
  JButton b1, b2, b3, bdiv, b5, b6, b7, bmult, b9, b10, b11, badd, b13, bdecimal, bequals, bsub,        bclear;
  String value, operation;
  double secondnum, total;
  public Calculator()
  {
    value = "";
    total = 0.0;
    secondnum = 0.0;
    f = new JFrame("Calculator");
    f.setSize(333,225);
    c = f.getContentPane();
    p = new JPanel();
    display = new JTextField(20);
    b1 = new JButton("7");
    b1.addActionListener(this);
    b2 = new JButton("8");
    b2.addActionListener(this);
    b3 = new JButton("9");
    b3.addActionListener(this);
    bdiv = new JButton("/");
    bdiv.addActionListener(this);
    b5 = new JButton("4");
    b5.addActionListener(this);
    b6 = new JButton("5");
    b6.addActionListener(this);
    b7 = new JButton("6");
    b7.addActionListener(this);
    bmult = new JButton("x");
    bmult.addActionListener(this);
    b9 = new JButton("1");
    b9.addActionListener(this);
    b10 = new JButton("2");
    b10.addActionListener(this);
    b11 = new JButton("3");
    b11.addActionListener(this);
    badd = new JButton("+");
    badd.addActionListener(this);
    b13 = new JButton("0");
    b13.addActionListener(this);
    bdecimal = new JButton(".");
    bdecimal.addActionListener(this);
    bequals = new JButton("=");
    bequals.addActionListener(this);
    bsub = new JButton("-");
    bsub.addActionListener(this);
    bclear = new JButton("C");
    bclear.addActionListener(this);
    p.setBackground(Color.green);
    p.add(display);
    p.add(b1);
    p.add(b2);
    p.add(b3);
    p.add(bdiv);
    p.add(b5);
    p.add(b6);
    p.add(b7);
    p.add(bmult);
    p.add(b9);
    p.add(b10);
    p.add(b11);
    p.add(badd);
    p.add(b13);
    p.add(bdecimal);
    p.add(bequals);
    p.add(bsub);
    p.add(bclear);
    c.add(p);
    f.show();
   }
   public void actionPerformed (ActionEvent event) 
      {
  
          if(event.getSource() == b1)
            {
                value = value + "7";
              }       
  
  
          if(event.getSource() == b2)
            {
               value = value + "8";
              }
  
  
          if(event.getSource() == b3)
            {
               value = value + "9";
              }  
  
  
  
  
          if(event.getSource() == b5)
            {
                value = value + "4";
              }
  
  
          if(event.getSource() == b6)
            {
                value = value + "5";
              }
  
  
          if(event.getSource() == b7)
            {
                value = value + "6";
              }
  
  
  
  
  
          if(event.getSource() == b9)
            {
               value = value + "1";
              }
  
  
          if(event.getSource() == b10)
            {
                value = value + "2";
              }
  
  
          if(event.getSource() == b11)
            {
                value = value + "3";
              }
  
  
  
  
  
          if(event.getSource() == b13)
            {
                value = value + "0";
              }
  
  
          if(event.getSource() == bdecimal)
            {
               value = value + ".";
              }  
  
           if(event.getSource() == badd)
            {
               total = Double.parseDouble(value);
                operation = "add";
                value = "";
              }
  
          if(event.getSource() == bmult)
            {
                total = Double.parseDouble(value);
                operation = "multiply";
                value = "";
              }
  
         if(event.getSource() == bsub)
            {
                 total = Double.parseDouble(value);
                operation = "subtract";
                value = "";
              }
  
          if(event.getSource() == bdiv)
            {
                total = Double.parseDouble(value);
                operation = "divide";
                value = "";
              }     
  
         if(event.getSource() == bclear)
            {
                total = 0.0;
                secondnum = 0.0;
                value = "";
              }
  
         if(event.getSource() == bequals)
         {
             secondnum = Double.parseDouble(value);
           {  
             if(operation.equals("add));
             total = total + secondnum;
          }
           {  
             if(operation.equals("subtract"));
             total = total - secondnum;
          }
             if(operation.equals("divide"));
             total = total / secondnum;
            {  
             if(operation.equals("multiply"));
             total = total * secondnum;
          }
          value = "" + tottal
          }
          display.setText(value);
     }
          }    
  </code></pre>
  
  <p>Any help is much appreciated, I realize it's probably just a stupid mistake.</p>