This is exactly what has been done to the collective Info submissions: each student's submission has been compiled and run, and the output from all of these programs has been collected in one large file. Assume that this file lists first the number of submissions overall, and then the information provided by each student on separate lines. Thus, the overall file has the following format:
678 | n = number of students |
Smith
Kelly 123456789 yu123456 A |
block of data for student 1 |
Chow
Yun Fat 987654321 hiddendragon B |
block of data for student 2 |
... | |
familyName_i
givenNames_i studentNr_i amlAccount_i section_i |
block of data for student n |
Write a programme which will read this input and print the family name and given names of each student in section B, in the format:
Chow, Yun FatYou should read all input from the standard input. Normally, this means the keyboard, but you can use redirection to read an input file instead. If your class is called LoopingProgram2 and you want to read in file inputFile.txt, then you should use the command:
% java LoopingProgram2 < info.txtNote: the angle bracket specifies which direction the data will flow. Thus, you could also redirect your output to a file rather than have it go to the default (i.e. your computer screen). For example:
% java HelloWorld > outputFile.txtTo do this program, you may use this sample file which includes the two names above.
Family Name : Doe Given Names : John Student Number : 123456789 AML Account ID : yu123456 Section : A