Reference no: EM132385022
Assignment -
A text document (i.e text file) student.txt contains the following information:
The text document is attached for you. The format of the information in Figure 1 is depicted as in the following order: The username is in the first position, followed by the first name of the student, the last name of the student and the age of a student.
You are required to write a program in Java which will allow any user to load data from the text document into a java array object and insert these data from the array object to a database:
1. Build a class "student" which will allow any other java classes to access the username, firstname, lastname and the age of a student object.
2. You will have to create an array of student objects. You will also have to load all the data from the text document student.txt into the array you created.
3. The user shall then be allowed to input any username to the program.
4. The program will then verify if the username input in part (3) is presently in the student array you created. If the username is not present in the student array, the program shall print on the screen "username is not present in the text document" and request the user to input username again.
5. If the username is present in the student array, the program shall print "Username is present in the text document".
6. If the username is present in the student array,, the program shall then connect to a database. Note: The database you choose is as per your choice.
7. The program shall store the following value retrieved from the array object and store them into two database tables.
The database fields are as followed: username,firstname, lastname and age into two database tables.
Details of tables:
"tbl_login" database table contains the following field names: id, username and password
"tbl_student" database table contains the following field names: id, username, first name, last name.
In both tables, id is the primary key and is auto generated.