problems running recursion. [SOLVED]

The program is supposed to check the summary total of a text document:

Sample

SUMMARY 01/29/2011 $-74.30 4

BUY 01/20/2011 $-58.12

SUMMARY 01/24/2011 $-104.69 2

BUY 01/21/2011 $-92.51

BUY 01/23/2011 $-12.18

BUY 01/25/2011 $-0.37

SELL 01/27/2011 $88.88

the number after the amount is the number of sub entries which make up that summary. The problem I am having is when I try to run a recursion, after the second thread completes instead of returning to the first thread and finishing it, it just returns the current count and terminates the program.

any help would be greatly appreciated!

here's the segment I am having trouble with,

he full code can be found at http://www.pastebay.net/307448

here's the segment I am having trouble with,

Code JAVA:

//method checks the accuracy of the summaries
public static double subCheck(int sumNum, double subTotal, Scanner in) throws IOException{
String date;
String amountString =null;
int x=sumNum;
double total=subTotal;
double amount=0;
double count=0;
double tTotal=0;
while (x>0){
// calls lineCheck to determine the first token of the line
amountString = lineCheck(in);
//if summary is returned as the first token method autoNum is
//called to get the number of sub entries that make up its total
if(amountString=="SUMMARY"){
date = lineCheck(in);
total = amountNum(in);
tTotal=total;
//number of sub entries is stored as x
String X=subNum(in);
//string x is changed to an int
x=Integer.parseInt(X);
//amountString is converted to null
amountString =null;
if(x>0)
//method calls its self to check summary total
return subCheck(x,total,in);
}
//checks the value of buy and sell, then adds the value into count
if(amountString!="SUMMARY"){
date=amountString;
amount=amountNum(in);
count=amount+count;
x--;
//temporary, prints out count so I can check that the program is making the proper calculations
System.out.println(count);
}
}
return count;
}

Re: problems running recursion, any help would be grealty appreciated!

Please Edit your post and wrap your code with[code=java]<YOUR CODE HERE>[/code] to get highlighting

Re: problems running recursion, any help would be grealty appreciated!

Sorry about that, I have updated my post.

Re: problems running recursion, any help would be grealty appreciated!

One thing that would be problem is using == or != to compare Strings. You should use the equals() method.

Your two if tests could be redundant.

If the first one is true, will the second one always be false. And visa versa.

Remove the second if and make it an else for the first if.