import java.util.Scanner;
import java.math.BigInteger;
public class Main
{
public static String format(String c,int l)
{
if(l==0)
return “\0”;
String s=c;
for(int i=1;i<l;++i)
s+=c;
return s;
}
public static void main(String [] args)
{
Scanner sc=new Scanner(System.in);
int T=sc.nextInt();
for(int i=0;i<T;++i)
{
String E=sc.next();
int id=E.indexOf(’+’)+E.indexOf(’-’)+E.indexOf(’’)+2;
String e1=E.substring(0,id);
String e2=E.substring(id+1);
int l1=e1.length(),l2=e2.length()+1;
char o=E.charAt(id);
if(o==’+’)
{
BigInteger n1,n2,R;
n1=new BigInteger(e1);
n2=new BigInteger(e2);
R=n1.add(n2);
String e3=R.toString();
int l3=e3.length();
int l=Math.max(Math.max(l1,l2),l3);
System.out.println(format(" “,l-l1)+e1);
System.out.println(format(” “,l-l2)+”+"+e2);
System.out.println(format(" “,l-Math.max(l2,l3))+format(”-",Math.max(l2,l3)));
System.out.println(format(" “,l-l3)+e3);
}
if(o==’-’)
{
BigInteger n1,n2,R;
n1=new BigInteger(e1);
n2=new BigInteger(e2);
R=n1.subtract(n2);
String e3=R.toString();
int l3=e3.length();
int l=Math.max(l1,l2);
System.out.println(format(” “,l-l1)+e1);
System.out.println(format(” “,l-l2)+”-"+e2);
System.out.println(format(" “,l-Math.max(l2,l3))+format(”-",Math.max(l2,l3)));
System.out.println(format(" ",l-l3)+e3);
}
if(o==’’)
{
BigInteger n1,n2,R;
n1=new BigInteger(e1);
n2=new BigInteger(e2);
R=n1.multiply(n2);
String e3=R.toString();
int l3=e3.length(),c=0;
int l=Math.max(l2,l3);
System.out.println(format(" “,l-l1)+e1);
System.out.println(format(” “,l-l2)+”*"+e2);
if(l2>2)
while(n2.compareTo(BigInteger.ZERO)>0)
{
BigInteger d=n2.remainder(BigInteger.TEN);
BigInteger temp=n1.multiply(d);
String et=temp.toString();
int lt=et.length();
if(c==0)
{
int t=Math.max(l2,lt);
System.out.println(format(" “,l-t)+format(”-",t));
System.out.println(format(" “,l-lt)+et);
}
else
System.out.println(format(” ",l-lt-c)+et);
n2=n2.divide(BigInteger.TEN);
++c;
}
System.out.println(format(" ",l-l3)+format("-",l3));
System.out.println(format(" ",l-l3)+e3);
}
System.out.println();
}
}
}
help me to figure out why it gives wrong answer