Looping multiple scanner inputs that work together until a specific input
<p>I am new to java, and I am doing this assignment for a romanCalculator.
I am currently done with the calculation part but i am having an issue with some of the rules requested.</p>

<p>I want 3 type of scanner inputs to work.</p>

<ol>
<li>(possible Roman number) (operator) 
<li>(operator) (possible Roman number)</li>
<li>.</li>
</ol>

<p>The first will take a roman numeral input and use any operator on another roman numeral input 
Roman numerals are [MMCDXLVI].</p>

<p>I was able to create the program which takes 2 roman numerals and u calculate them depending on the operator input, but I wasn't able to have the second rule work.</p>

<p>It means if there's a result from rule #1, and i type (operator) (possible Roman number), it will calculate the last Roman number( the result) with the new input.</p>

<p>For example:</p>

<blockquote>
<pre><code> X + I (input)

 XI    (output)

 * II  (input)

 XXII  (output)
</code></pre>
</blockquote>

<p>So how do i make that work, how to have 2 viable inputs only and the second input uses the result of the first input.</p>

<p>This is all what i could do with my knowledge:</p>

<pre><code>    Scanner in = new Scanner(System.in);
    String input = "";

    while(!(input = in.nextLine()).equals("."))
    {
        String[] userInput = input.split("\\s+");



        if(userInput.length == 3)


        {
            String firstRoman = userInput[0];
            String operator = userInput[1];
            String secondRoman = userInput[2];

            int romanConvertedNumber = (compute(romanToNumber(firstRoman), operator, romanToNumber(secondRoman)));



            if(firstRoman.matches("[MCDXLVImcdxlvi]+") &amp;&amp; operator.matches("\\+|\\-|\\*|\\/") &amp;&amp; secondRoman.matches("[MCDXLVImcdxlvi]+"))
            {

                IntegerToRomanNumeral(romanConvertedNumber); //method to convert number to roman

            }


        }

        else{
            System.out.println("Error: Wrong input");
        }
    }

}
</code></pre>

<p>It works for the first case only like said and terminates when i write (.), I don't how to apply to the result i get to (operator) (possible roman Number) like in the example, I'd appreciate any help. Thanks!</p>