Given numrows and numcols, 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 numcols = 3 prints: 1a 1b 1c 2a 2b 2c

Respuesta :

/* package whatever; // don't place package name! */

import java.util.*;

import java.lang.*;

import java.io.*;

class NestedLoops {

public static void main (String [] args) {

int numRows = 4;

int numCols = 5;

int i,j;

char ch = 'A';

// Note: You'll need to declare more variables

/* Your solution goes here */

for ( i = 0; i < numRows; i++) { // Outer loop runs for numRows times

for ( j = 0; j < numCols; j++) { // Inner loop runs for numCols times

System.out.print(i+1);

System.out.print((char)(ch+j));

System.out.print(" ");

}

}

System.out.println("");

return;

}

}

ACCESS MORE