diff --git a/Basics_II/src/main/java/com/example/BasicII.java b/Basics_II/src/main/java/com/example/BasicII.java index 1656b28..2e9b4b5 100644 --- a/Basics_II/src/main/java/com/example/BasicII.java +++ b/Basics_II/src/main/java/com/example/BasicII.java @@ -45,5 +45,31 @@ public class BasicII { //Multidimensional arrays (row, col) int[ ][ ] sample = { {1, 2, 3}, {4, 5, 6} }; System.out.println(sample[0][2]); + + /* + You are creating a ticketing program for a small movie theater. + The seats are represented using a 2-dimensional array. + Each item can have the values 1 and 0 - 1 is occupied, and 0 if it's free. + Your program needs to take as input the row and the column of the seat and output Free if it's free, and Sold if it's not. + */ + 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} + }; + System.out.print("The row you want: "); + int row = sc.nextInt(); + System.out.print("The column you want: "); + int col = sc.nextInt(); + + if (seats[row][col] > 0) { + System.out.println("Sold"); + }else{ + System.out.println("Free"); + } + + } } \ No newline at end of file diff --git a/Basics_II/target/classes/com/example/BasicII.class b/Basics_II/target/classes/com/example/BasicII.class index a13875e..2bfbf09 100644 Binary files a/Basics_II/target/classes/com/example/BasicII.class and b/Basics_II/target/classes/com/example/BasicII.class differ