Hello I am trying to make a random Multiplication question generator with the answer in this style.
850702
× 841
-------------------
850702
3402808×
6805616××
-------------------
715440382
-------------------
But I am getting this.
850702
× 841
-------------------
850702 (comment )
3402808× <- in this lines
6805616×× <-|
-------------------
715440382
-------------------
When its multiply each number of the second number it doesnt gives the space for × sign that i want (check that arrow in the comment of given output) .
Here is the source code
import java.lang.Math.*;
class Mainto {
public static void main (String[] args) {
//Adding sone gap between output and console
System.out.println(" ");
//Generating first number to multiply
double a = Math.random()*(999999-100000+1)+100000;
long num1 = (long)a;
//Generating second number to multiply it
double b = Math.random()*(999-10+1)+10;
long num2 = (long)b;
//printing the num1 and num2 of question
System.out.println(" "+num1);
System.out.println("× "+num2);
System.out.println("-------------------");
//Multiplying every single number of num2 with num1
long mul=num2;
String nothing="";
while(mul!=0){
long d= mul %10;
System.out.println(d*num1+nothing);
mul /=10;
nothing+="×";
}
//Multiplying number and printing it
long c=num1*num2;
System.out.println("-------------------");
System.out.println(c);
System.out.println("-------------------");
//Adding some gap in every question to make it easy to read
System.out.println(" ");
System.out.println(" ");
}
}