Answer:
This question is not complete, here's the complete question:
The program is run using the following command:
java programName #row #cols < students.txt
#rows and #cols are integers indicating the number of rows and columns of seats in the
classroom. students.txt is a text file holding the student names.
a) (5 points) Write a code-segment to:
1. Declare a 1-D String array variable, studentLine, that has space to hold all
students in the class in a single line. (Figures 1 and 3)
2. Declare a 2-D String array variable, room, to represent the seats in the classroom
where the number of rows and number of columns are given as command line input.
Step-by-step explanation:
a) 1 -> String[] studentLine = new String[Integer.parseInt(args[0]) * Integer.parseInt(args[1])];
2 -> String[][] room = new String[Integer.parseInt(args[0])][ Integer.parseInt(args[1])];
b)
public static void fillLine(String[] a){ try { File f=new File("students.txt"); FileReader fr=new FileReader(f); BufferedReader br=new BufferedReader(fr); String l; int index = 0; while((l = br.readLine())!=null) { a[index] = l; index++; } fr.close(); } catch(IOException e) { e.printStackTrace(); } }