AnotherModulePassed

This commit is contained in:
2024-09-13 09:49:48 +02:00
parent 827d99c3f2
commit 16fc065973
2 changed files with 26 additions and 0 deletions

View File

@ -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");
}
}
}