title: Java - Getting the answer to a calculation using variables
body: <p>How can I return the answer to a calculation where the two numbers and operator used are stored in variables (<em>input from the user</em>).</p>
  
  <p>I am creating a simple calculator and trying to output the answer to <strong><em>"Number" "Operator" "Number2"</em></strong> which can be anything depending on what the user inputs.</p>
  
  <pre><code>int Number;
  int Number2;
  int Operator;
  String OperatorString;
  
  do 
  {
      System.out.println("Enter a number");
      Number = UserInputScanner.nextInt();
  
      System.out.println("1. + \n");
      System.out.println("2. - \n");
      System.out.println("3. * \n");
      System.out.println("4. / \n");
  
      Operator = UserInputScanner.nextInt(); 
  
         switch (Operator) {
          case 1:  OperatorString = "+";          
                   break;
          case 2:  OperatorString = "-";
                   break;
          case 3:  OperatorString = "*";
                   break;
          case 4:  OperatorString = "/";
                   break;
          default: OperatorString = "Invalid Operator";
                   break;
      }
      System.out.println(OperatorString);
  
      System.out.println("Enter another number");
      Number2 = UserInputScanner.nextInt();       
  
      Answer = "Number" + "OperatorString" + "Number2";
      System.out.println(Number + OperatorString + Number2 + "=" + Answer);
  </code></pre>
  
  <p>The output from this when inputting these numbers and operator returns "5+5=5+5" and I am trying to return "5+5=10".</p>