Question

In: Computer Science

in java Print a list of seats in a theater. Rows are numbered, columns lettered, as...

in java Print a list of seats in a theater. Rows are numbered, columns lettered, as in 1A or 3E.

Print a space after each seat. Create a nested loop to print the following: 1A 1B 1C 1D 3A 3B 3C 3D 5A 5B 5C 5D

Solutions

Expert Solution

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();

    for(currentRow=1;currentRow<=numRows;currentRow++){
      currentColumnLetter = 'A';
      for(currentColumn=0;currentColumn<numColumns;currentColumn++){
        System.out.print(""+currentRow+currentColumnLetter+" ");
        currentColumnLetter += 1;
      }
    }

    System.out.println("");
  }
}


Related Solutions

Given numRows and numColumns, print a list of all seats in a theater. Rows are numbered, columns lettered, as in 1A or 3E.
4.8.2: Nested loops: Print seats. C++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. Ex: numRows = 2 and numColumns = 3 prints:1A 1B 1C 2A 2B 2C#includeusing namespace std;int main() {int numRows;int numColumns;int currentRow;int currentColumn;char currentColumnLetter;cin >> numRows;cin >> numColumns;/* Your solution goes here */cout << endl;return 0;}
Given numRows and numColumns, print a list of all seats in a theater. Rows are numbered,...
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);      ...
Given numRows and numCols, print a list of all seats in a theater. Rows are numbered,...
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. Ex: numRows = 2 and numCols = 3 prints: 1A 1B 1C 2A 2B 2C #include <iostream> using namespace std; int main() {    int numRows = 2;    int numCols = 3;    // Note: You'll need to define more variables    /* Your solution goes...
Given numRows and numCols, print a list of all seats in atheater. Rows are numbered,...
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. Ex: numRows = 2 and numCols = 3 prints:1A 1B 1C 2A 2B 2C#includeint main(void) {int numRows = 2;int numCols = 3;// Note: You'll need to declare more variables/* Your solution goes here */printf("\n");return 0;}
A Theater has n numbered seats, and n tickets are distributed among n persons. Compute the...
A Theater has n numbered seats, and n tickets are distributed among n persons. Compute the probability that (a) exactly two persons will be seated at seats corresponding to their ticket numbers if all the seats are occupied at random. (b) at least two persons will be seated at seats corresponding to their ticket numbers if all the seats are occupied at random.
JAVA If a user inputs a specific number of rows, columns and sections for a rectangle...
JAVA If a user inputs a specific number of rows, columns and sections for a rectangle using three symbols, how would you print using for loops and a string? Not using an array Example: If 4 was inputted for rows, 12 was inputted for columns, 6 was inputted for sections, and the following symbols (that are all chosen by the user) were “$” “*” and “%” the following would print: $$**%%$$**%% $$**%%$$**%% $$**%%$$**%% $$**%%$$**%% Has to account for all numbers...
SOLVE IN C: Given numRows and numColumns, print a list of allseats in a theater....
SOLVE IN C: 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. Ex: numRows = 2 and numColumns = 3 prints:1A 1B 1C 2A 2B 2C
JAVA LANGUAGE Write a program that declares a 2-Dimensional Array with 4 rows and 4 columns...
JAVA LANGUAGE Write a program that declares a 2-Dimensional Array with 4 rows and 4 columns to store integer values, and then: fill elements with values as the sum of its column index and row index, e.g., the element at row index 0 and column index 0 is (0+0=0), the element at row index 0 and column index 1 is (0+1=1). compute the sum of elements at the second row. compute the sum of elements at the third column. compute...
JAVA programing language: What is printed when the following code is executed? int columns; int rows;...
JAVA programing language: What is printed when the following code is executed? int columns; int rows; for(rows = 1; rows < 2; ++rows) { for(columns = 1; columns < 3; ++columns) { System.out.print("x"); } System.out.println(): } select one: A) xx B) xxx xxx C) x x D) xx xx xx
Assume that A and B are MATLAB arrays with 10 rows and an equal number of columns (the number of columns is not given).
Assume that A and B are MATLAB arrays with 10 rows and an equal number of columns (the number of columns is not given). Important: Next, the expression "a single line of code" implies a single command or equality. In other words, the code: X=A+1; X=X+B; is considered to be TWO lines of code, even though it can be written as one line. (a) (3%) Write a single line of code which saves the first two rows of array A...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT