title: How to turn a string into an operator in Java?
body: <p>I'm trying to make a simple text based calculator in java <em>my first program, EVER</em> and I can't figure out how to turn an input <code>String</code> into a variable <code>opOne</code>. I would then attempt to operate <code>numOne</code> against <code>numTwo</code> using <code>opOne</code> as the operator. 
  Code is as follows:</p>
  
  <pre><code>import java.io.*;
  import java.math.*;
  
  public class ReadString {
  
     public static void main (String[] args) {
  
  
        System.out.print("Enter the first number: ");
  
  
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 
        int numOne = 0 ;
        int numTwo = 0 ;
        String opOne = null;
  
        while(true){
        try {
            numOne = Integer.valueOf(br.readLine());
            break;
        } catch (IOException error) {
           System.out.println("error; try again.");
           System.exit(1);
        }
        catch (NumberFormatException nfe) {
            System.out.println("error;try again.");
  
        }
  
        }
  
        System.out.print("Enter the second number: ");
  
        while(true){
        try {
  
            numTwo = Integer.valueOf(br.readLine());
            break;
         } catch (IOException error2) {
            System.out.println("error");
            System.exit(1);
         } catch (NumberFormatException nfe) {
            System.out.println("error;try again.");
  
         }
        }
  
        System.out.println("What would you like to do with " + numOne + " and " + numTwo + "?");
  
        try {
            operator = br.readLine();
         } catch (IOException ioe) {
            System.out.println("error");
            System.exit(1);
         } catch (NumberFormatException nfe) {
            System.out.println("error");
  
         } 
     }
  }
  </code></pre>