University
that is randomly generated
using the appropriate method (Hint: see API
of the class University
which is part of the labtest
package).
Print all the students of the generated University
.
Here is a sample run:
7258991 -- SCIENCE 4787548 -- BUSINESS 6556476 -- ARTS 9980310 -- ARTS 3081836 -- SCIENCE
Enter file name:The entry has to be made on the same line as the prompt. If the file does not exist, then the message
File does not exist!
has to be printed and the user has to be reprompted
until an existing file name is entered.
To test your program, you may use the file university.txt
with the following
content.
Jane,3487465,SCIENCE John,4568765,ARTS Janet,4357435,BUSINESS Jane,3487465,BUSINESSHere is a sample run:
7258991 -- SCIENCE 4787548 -- BUSINESS 6556476 -- ARTS 9980310 -- ARTS 3081836 -- SCIENCE Enter file name: bla File does not exist! Enter file name: university.txt
StringTokenizer
)
and create a corresponding Student
object and add it to the University
object. For example, add a ScienceStudent
object with number 3487465
.
If a Student
object with the same number is already present in
the collection of Student
s, then the Student
should
not be added and a warning should be printed. (Hint: see API
of University
.) Note that successful additions do not produce any
output.
Here is a sample run:
7258991 -- SCIENCE 4787548 -- BUSINESS 6556476 -- ARTS 9980310 -- ARTS 3081836 -- SCIENCE Enter file name: bla File does not exist! Enter file name: university.txt Warning: Student with number 3487465 is already present