java won't break up a user input with multiple double and char variables using Scanner and System.in
<p>I want the user to input a math equation using one of these variables: *, /, +, - </p>

<p>Input Examples (with no spaces) :    2*2,    35.7/3,    4.5+5.5</p>

<p>Then I want to break the first number, char variable, and second number apart and store them into separate variables.</p>

<p>When I use this code:</p>

<pre><code>import java.io.*;
import java.util.Scanner;

class Extra {
    public static void main (String[] args) throws IOException {

        double fnum, snum;
        char operator;

        System.out.println("Type Operation.");
        Scanner s = new Scanner ( System.in );

        fnum = s.nextDouble();
        operator = s.next().charAt(fnum + 1);
        snum = s.nextDouble();

        System.out.println(fnum);
        System.out.println(snum);
        System.out.println(operator);

        s.close();
    }
}
</code></pre>

<p>I get this error/response:</p>

<pre><code>Type Operation.
2*2

Exception in thread "main" java.util.InputMismatchException

   at java.util.Scanner.throwFor(Unknown Source)

   at java.util.Scanner.next(Unknown Source)

   at java.util.Scanner.nextInt(Unknown Source)

   at java.util.Scanner.nextInt(Unknown Source)

   at Extra.main(Extra.java:24)
</code></pre>

<p>I really want to use something like this:</p>

<pre><code>operator = s.next("[*,/,+,-]").charAt(fnum + 1);
</code></pre>

<p>Please Help, I don't know what I'm doing wrong.</p>