title: Building a basic calculator in Java and need to check validity of the math expression input by the user
body: <p>I am building a basic calculator in Java and have a few requirements to meet for it. it takes a math expression input from the user example. 3 * 5 ^ 5 (must be separated by spaces).
  I'm having trouble figuring out how to pass the basic math expression input string math to the isNumber function and then in that function checking the first [0] spot of the string and every 4th spot (since spaces are still in there?) after for a double. I can do it if I turn math into a string array, but the requirements specifically said I cannot turn string math into an array until afterwards. I know if I can figure this out, then it shouldn't be hard to make an operator validation function and do the same for the spots of the input...
  here is my current progress on the program.</p>
  <pre><code>import java.util.Scanner;
  
  /**
   *
   * @author 
   */
  public class Calculator2 {
      static ArrayList&lt;String&gt; validOperators = new ArrayList&lt;String&gt;(){{
              add(&quot;^&quot;);
              add(&quot;*&quot;);
              add(&quot;/&quot;);
              add(&quot;+&quot;);
              add(&quot;-&quot;);
          }}; 
      
      public static void main(String[] args) {
          System.out.println(&quot;This is a text based calculator!&quot;);
          Scanner in = new Scanner(System.in);        
          boolean loop = true;
          while (loop) {
              System.out.println(&quot;Enter a math expression ot type quit to exit: &quot;);
              String math = in.nextLine();
              if (&quot;quit&quot;.equalsIgnoreCase(math)) {
                  System.out.print(&quot;Quitting&quot;);
                  break;
              }
              
               if (isOperator(math)){
                   if (isNumber(math)){
                     String[] splitExpression = math.split(&quot;\\s+&quot;);
                       if(isValidExpression(splitExpression)){
                           for (int i=0; i&lt;splitExpression.length; i++){
                               System.out.println(splitExpression[i]);
                      } 
                      System.out.println(&quot;Number of tokens: &quot; + splitExpression.length);
                   }
                   }else {
                       System.out.println(&quot;invalid expression!&quot;);
                   }
               }else{
                   System.out.println(&quot;please use valid operators&quot;);
               }
              
              
          }
      }
      
      public static boolean isNumber(String number){
          return 
      }
  } ```
  </code></pre>