-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClassroom.java
More file actions
78 lines (59 loc) · 1.53 KB
/
Classroom.java
File metadata and controls
78 lines (59 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
public class Classroom
{
public static void main (String[] args) {
int row = 0;
int column = 0;
char[][] classroom= new char[5][6];
for(int x = 0; x < classroom.length; x++)
{
for(int y = 0; y < classroom[x].length; y++)
{
classroom[x][y]='-';
}
}
for(int x = 0; x < classroom.length; x++)
{
for(int y = 0; y < classroom[x].length; y++)
{
System.out.print(classroom[x][y]);
}
System.out.println ();
}
for(int z = 0; z < 3; z++)
{
row = 0;
column = 0;
System.out.println("\nWhere would you like to place a student?");
System.out.print("Row: ");
row = SavitchIn.readLineInt();
System.out.print("Column: ");
column = SavitchIn.readLineInt();
while((row < 0 || row > 5) || (column < 0 || column > 6))
{
System.out.println ("Not a valid seat, try again");
System.out.print("Row: ");
row = SavitchIn.readLineInt();
System.out.print("Column: ");
column = SavitchIn.readLineInt();
while(classroom[row][column]=='s')
{
System.out.println ("seat taken, try again");
System.out.print("Row: ");
row = SavitchIn.readLineInt();
System.out.print("Column: ");
column = SavitchIn.readLineInt();
}
}
classroom[row][column]='s';
}
System.out.println("\nHere is the new chart:");
for(int x = 0; x < classroom.length; x++)
{
for(int y = 0; y < classroom[x].length; y++)
{
System.out.print(classroom[x][y]);
}
System.out.println ();
}
}
}