Ask Question
28 January, 03:22

In Java; Given numRows and numColumns, print a list of all seats in a theater. Rows are numbered, columns lettered, as in 1A or 3E. Print a space after each seat, including after the last. Use separate print statements to print the row and column. Ex: numRows = 2 and numColumns = 3 prints:

1A 1B 1C 2A 2B 2C

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;

numRows = scnr. nextInt ();

numColumns = scnr. nextInt ();

numColumns = currentColumnLetter

for (currentRow = 0; currentRow < numRows; currentRow++) {

for (currentColumn = =

System. out. println ("");

}

}

+3
Answers (1)
  1. 28 January, 05:42
    0
    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.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “In Java; Given numRows and numColumns, print a list of all seats in a theater. Rows are numbered, columns lettered, as in 1A or 3E. Print a ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers