AnotherModulePassed
This commit is contained in:
@ -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");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
Binary file not shown.
Reference in New Issue
Block a user