I am trying to do this program but I can't get it to work correctly.
For example If I put (2 * (2 + (4 + 5)))*(7 + (3)) as input I want the output to be like x * (2 + 4 + 5) * (7 + 3).
But I get 2 * (2 + (4 +5) * (7 + 3).
In other words I want the asInfix method to print the infix expression using minimum number of parentheses.
Here is the method.

public static void asInfix(BinaryTree exprTree)
{
if(!exprTree.isEmpty())
{
BinaryTree parent = exprTree;
boolean inMultOrDiv = (parent==null)?false(parent.value().equals("*")||parent.value().equals("/"))&&
(exprTree.value().equals("/") || exprTree.value().equals("*")));
boolean printParent = (inMultOrDiv && (exprTree.value().equals("+")) || exprTree.value().equals("-") &&
(parent.value().equals("-")) || parent.value().equals("+"));


if(printParent){ System.out.print("(");}
PrintTree.asInfix(exprTree.left());
System.out.print(exprTree.value() + " " );
PrintTree.asInfix(exprTree.right());
if(printParent){ System.out.print(")");}
}
}
Please help me, I am really running out of time. This is due tomorrow night. Than you, than you....