title: Reading mathematical expressions from user input
body: <p>I need to be able to read in user input and break it apart for later use. The user can input whole or fractional numbers and an operation, and I'm not sure how to read this in.</p>
  
  <p>An example of user input is <code>4/8 – 3/12</code> or <code>3 + 2/3</code> or <code>12/16 * 4</code> or <code>-2/3 / 64/96</code>.</p>
  
  <p>Right now I'm using something like this:</p>
  
  <pre><code>public class FractionApp 
  {
  public static void main(String[] args){
      Scanner s = new Scanner(System.in);
      int[] fraction = new int[5];
      String input;
      String operation;
      System.out.println("Enter the expression: ");
      input = s.next();
      StringTokenizer st = new StringTokenizer (input, "/" + " ");
      fraction[0] = Integer.parseInt(st.nextToken());
      fraction[1] = Integer.parseInt(st.nextToken());
      operation = st.nextToken();
      fraction[2] = Integer.parseInt(st.nextToken());
      fraction[3] = Integer.parseInt(st.nextToken());
  
  
      }
  }
  </code></pre>