title: Java Command Prompt Calculator - Homework
body: <p>I need a Java program that acts as a calculator in the command prompt. I could come up with this, but I have to input the problem one at a time(put in "2", push enter, put in "+", push enter, put in "2", push enter) and I wanted to know if I could make it where I can just put in "2+2" instead. Thanks in advance for any help!</p>
  
  <pre><code>import java.util.*;
  
  public class memCalc
  {
      public static void main (String args[])
      {
          Scanner input = new Scanner(System.in);
          String op;
          int numberOne, numberTwo, result = 0;
          numberOne = input.nextInt();
          op = input.next();
          numberTwo = input.nextInt();
          if (op.equals("+"))
          {
              result = numberOne + numberTwo;
              System.out.print("The answer is: " + result + " .\n");
          }
          else if (op.equals("-"))
          {
              result = numberOne - numberTwo;
              System.out.print("The answer is: " + result + " .\n");
          }
          else if (op.equals("*")) 
          {
              result = numberOne * numberTwo;
              System.out.print("The answer is: " + result + " .\n");
          }
          else if (op.equals("/"))
          {
              result = numberOne / numberTwo;
              System.out.print("The answer is: " + result + " .\n");
          }
      }
  }
  </code></pre>