title: String expressions with four operators
body: <p>CS Student here. I want to be able to take a string such as '2+2*3/2-2' and evaluate it (= 3). But I'm not sure how to structure the code to follow the proper order of operations. Here's code for multiplication and division:</p>
  
  <pre><code>int r = 1;
      int n = 0;
      char op = '*';
  
      for (int i = 0; i &lt; E.length(); i++)
          if (E.charAt(i)=='*'||E.charAt(i)=='/')
          {
              if (op == '*')
                  r *= n;
              else
                  r /= n;
              n = 0;
              op = E.charAt(i);
          }
          else
              n = n*10 + (E.charAt(i)-'0');
  
      if (op == '*')
          r *= n;
      else
          r /= n;
  
      return r;
  </code></pre>
  
  <p>Thanks for reading!</p>