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 rows and columns.
Create a nested for loop, outer loop goes until numRows and inner loop goes until numRows.
Inside the first loop, set currentColumn to 1 and currentColumnLetter 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 - i, and currentColumnLetter. Also,increment currentColumn and currentColumnLetter values by 1.