Answer:
import java.util.Scanner;
public class NestedLoops
{
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
int numRows;
int numColumns;
int currentRow;
int currentColumn;
char currentColumnLetter;
System.out.print("Enter number of rows: ");
numRows = scnr.nextInt();
System.out.print("Enter number of columns: ");
numColumns = scnr.nextInt();
for(int i = 1; i <= numRows; i++){
currentColumn = 1;
currentColumnLetter = 'A';
for(int j = 1; j <= numColumns; j++){
System.out.print("" + i + currentColumnLetter + " ");
currentColumn++;
currentColumnLetter++;
}
}
}
}
Explanation:
Ask user to enter the number of <em>rows</em> and <em>columns</em>.
Create a nested for loop, outer loop goes until <em>numRows</em> and inner loop goes until <em>numRows</em>.
Inside the first loop, set <em>currentColumn</em> to 1 and <em>currentColumnLetter</em> to 'A'. This way for after each row column value starts from 1 and letter value starts from A.
Insite the second loop, print the row value - <em>i</em>, and <em>currentColumnLetter</em>. Also,increment <em>currentColumn</em> and <em>currentColumnLetter</em> values by 1.