.
Goal is for user to input 2 numbers then get a multiplication chart with a row and column.
Example: user enters 3 and 5, then should print
...3 4 5 (disregard the dots)
3 9 12 15
4 12 16 20
5 15 20 25
My program will not correctly put the chart next to the column but the chart itself multiplies correctly. any suggestions?
import java.util.*;
class ForLoop1{
public static void main (String [] args){
Scanner scan = new Scanner(System.in);
System.out.println();
System.out.println("Multiplication Table");
System.out.println();
System.out.println("Enter Values");
int a = scan.nextInt();
int b = scan.nextInt();
if(a>b){
int c = a;
int d = b;
a = d;
b = c;
}
for(int q=a;q<=b;q++){
System.out.print("\t"+q+"\t");
}
for(int q=a;q<=b;q++){
System.out.print("\n"+q);
}
System.out.println();
for(int i = a; i<=b; i++){
for(int j = a; j<=b; j++){
System.out.print("\t"+i*j+"\t");
}
System.out.println("\n");
}
}
}