I need to write a program that goes through a seating chart row by row and find n consecutive seats in a row. If the seating charts has seats available, it must print out the message saying in what row and what seats. If there are no seats available, it must return the message: "There's no group of seats to satisfy your request." It must also print out the seating chart I need help on how to find the n consecutive seats and find the row and number of the seats. Here's what I have so far:"
Code:
import java.util.Scanner;
public class TheaterSeating
{
public static void main( String args[] )
{
int[][] grid; // declare 2D array reference variable
int M = 12;
int N = 12;
int K = 4;
grid = new int[M][N]; // create 2D array
for (int i = 0; i<N; i++)
{
for (int j = 0; j< M; j++)
{
grid [i][j] = (int)(2*Math.random());
}
}
System.out.println("The current seating chart is:");
printSeats(grid, M, N);
}
public static void printSeats(int seat[][], int N, int M)
{
for (int i = 0; i<N; i++)
{
for (int j = 0; j< M; j++)
{
System.out.print(seat[i][j]);
}
System.out.println("");
}
}
}