You are creating a ticketing program for a small movie theater. The seats are represented using a 2-dimensional array.
import java.util.Scanner; public class Program { public static void main(String[] args) { int[][] seats = { {0, 0, 0, 1, 1, 1, 0, 0, 1, 1}, {1, 1, 0, 1, 0, 1, 1, 0, 0, 0}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {0, 0, 0, 1, 1, 1, 1, 0, 0, 0}, {0, 1, 1, 1, 0, 0, 0, 1, 1, 1} }; Scanner sc = new Scanner(System.in); int row = sc.nextInt(); int col = sc.nextInt(); if (row < 1 || row > seats.length || col < 1 || col > seats[0].length) { System.out.println("Invalid seat position"); } else { if (seats[row - 1][col - 1] == 0) { System.out.println("Sold"); } else { System.out.println("Free"); } } sc.close(); This is my code it passing the 3 test cases but giving error for two