50.1k views
5 votes
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 java

User Memoizer
by
5.8k points

1 Answer

5 votes

Answer:

public class MyClass {

public static void main(String args[]) {

for(int i =1; i<=5;i+=2){

for(char j ='A'; j<='D';j++){

System.out.print(i);

System.out.print(j+" ");

}

}

}

}

Step-by-step explanation:

This line iterates through 1 to 5 wit an increment of 2

for(int i =1; i<=5;i+=2){

This line iterates through alphabets A to E

for(char j ='A'; j<='D';j++){

This line prints the seat numbers (1, 3 and 5)

System.out.print(i);

This line prints the seat letters(A-E)

System.out.print(j+" ");

}

}

User Peduxe
by
5.4k points