Hello! I am working on a program that performs mathematical operations on a complex number. I have all the code compiled and am trying to get through the run-time errors. My hunch is that I am doing something wrong with the fromString method since regardless of how many complex numbers I input (in postfix), it only returns the first complex number. Any ideas?
Thanks! Andy

Java Code:
package complexnumbers;

import complexnumbers.*;
import java.util.*;
import java.io.*;

public class Project2 {
  public static void main (String[] args){
     
    String charConv = "null";
    String more = "null";
    char nextChar = '0';
    Stack theStack = new Stack();
    Scanner keyboard = new Scanner(System.in);
        
    do{
  //allow user to enter and evaluate any number of expressions
  System.out.println("Enter a postfix expression of complex numbers (Ex: ( 2 + 3 i ) ( 1 + 10 i ) + ):");
  StringTokenizer input = new StringTokenizer(keyboard.nextLine());  
    //System.out.println(input.countTokens());
  while (input.hasMoreTokens()){
    charConv = input.nextToken();
    nextChar = charConv.charAt(0);
    switch (nextChar){
    case '(':
      //System.out.println(input.nextToken());
      StringTokenizer expression = new StringTokenizer(input.nextToken(")"));
      Complex newComplex = Complex.fromString(expression);
      //System.out.println(newComplex.toString());
      theStack.push(newComplex); //push the value onto the stack
      break;
      case '+':
      case '-':
      case '*':
        //pop two operands from the stack
        Complex num1 = (Complex)theStack.pop();
        Complex num2 = (Complex)theStack.pop();
        //evaluate
        Complex result = evaluate(num1, num2, nextChar);
        theStack.push(result);
        break;
    }
  }
  //pop the final result off the stack
    Complex finalResult = (Complex)theStack.pop();
    System.out.println("The result of your input is:" + finalResult.toString());
    //System.out.println(input.nextToken());
    System.out.println("Evaluate another expression? (Y = Yes):");
    more = keyboard.nextLine();
    } while (more.equalsIgnoreCase("y"));
    }

  static public Complex evaluate(Complex num1, Complex num2, char operator){
    Complex result = new Complex();

    //evaluate operation
    if (operator == '+'){
      result = Complex.add(num1, num2);
    }
    else if (operator == '-'){
      result = Complex.subtract(num1, num2);
    }
    else {
      result = Complex.multiply(num1, num2);
    }
    return result;
  }
}
and the heavy lifting class (with the suspect method):

Java Code:
package complexnumbers;

import complexnumbers.*;
import java.util.*;
import java.io.*;

public class Complex{
  private double real, imag;
  private String oper;
    
  public Complex(){
  }
  
  public Complex(double real, double imag, String oper){
    this.real = real;
    this.imag = imag;
    this.oper = oper;
  }
      
  public static Complex fromString(StringTokenizer tokenizer){
    double real, imag;
    String oper;
    //System.out.println(tokenizer.nextToken());
    real = Double.parseDouble(tokenizer.nextToken());
    oper = tokenizer.nextToken();
    imag = Double.parseDouble(tokenizer.nextToken());
    return new Complex(real, imag, oper);
  }
  
  public String toString(){
    return "(" + real + " " + oper + " " + imag + "i" + ")";
  }
  
  static public Complex add(Complex num1, Complex num2){
    num1.real = num1.real + num2.real;
    num1.imag = num1.imag + num2.imag;
    return num1; 
  }
  
  static public Complex subtract(Complex num1, Complex num2){
    num1.real = num1.real - num2.real;
    num1.imag = num1.imag - num2.imag;
    return num1;
  }
  
  static public Complex multiply(Complex num1, Complex num2){
    int x1 = (int)num1.real;
    int y1 = (int)num1.imag;
    int x2 = (int)num2.real;
    int y2 = (int)num2.imag;
    int intTemp, iTemp = 0;
    
    intTemp = x1 * x2;
    x1 = x1 * y2;
    iTemp = y1 * x2;
    y1 = y1 * y2;
    y1 = y1 * (-1);
    
    x2 = intTemp + y1;
    y2 = x1 + iTemp;
    
    num1.real = x2;
    num1.imag = y2;
    
    return num1;
  }
}