Updated answer:
Following is one way to achieve what you are trying to achieve using while loop.
public static void main(String[] args)
{
int numOne; int numTwo;
Scanner input= new java.util.Scanner(System.in);
//Get First value
System.out.println("First number:");
numOne = input.nextInt();
//Get Second value
System.out.println("Second number:");
numTwo=input.nextInt();
input.close();
int x=1;
int y=1;
System.out.print(" ");
while(x<=numOne)
{
System.out.print(" [ x="+ x +" ] ");
x++;
}
x=1;y=1;
while(y<=numTwo)
{
System.out.println();
System.out.print("[y="+ y +"]");
while(x<=numOne)
{
int tResult=x%y;
System.out.print(" [("+ x +"%"+ y +")"+tResult+"] ");
x++;
}
y++;
x=1;
}
}
Sample output:
First number:
4
Second number:
5
[ x=1 ] [ x=2 ] [ x=3 ] [ x=4 ]
[y=1] [(1%1)0] [(2%1)0] [(3%1)0] [(4%1)0]
[y=2] [(1%2)1] [(2%2)0] [(3%2)1] [(4%2)0]
[y=3] [(1%3)1] [(2%3)2] [(3%3)0] [(4%3)1]
[y=4] [(1%4)1] [(2%4)2] [(3%4)3] [(4%4)0]
[y=5] [(1%5)1] [(2%5)2] [(3%5)3] [(4%5)4]