Question: (20 Marks)
You are required to write a program in java that will have two classes i.e. Person and Student.
1. Person will be the super / parent class and it will have four data members i.e. CNIC, Name, Date of Birth and Address. Person class will have a parameterized constructor (that will initialize all the data members with the given values) along with getters and setters for each data member that will get and set the values of data members of the class.
2. Student will be the child class and it will be inherited from Person class. It will have three data members i.e. Student ID, Study Program and Email. Student class will also have a parameterized constructor (that will initialize all the data members with the given values), getters and setters for each data member (that will get and set the values of data members of the class) and a main method. In main method, you’ll will show following options to user and take user choice by using JOptionPane.showInputDialog.
- Press 1 to add a new student.
- Press 2 to display all students.
- Press 3 to exit.
If user enters 1 then take the values of CNIC, Name, Date of Birth, Address, Student ID, Study Program and Email using JOptionPane.showInputDialog and create an instance of Student class by using its parameterized constructor. Now, store all this information in a text file (students.txt) separated by commas ( , ) in a single line. Whenever, user enters a new record then it should not affect the previous records in text file. Note that you have to enter your own information while entering first record.
If user enters 2 then display record of all the students available in students.txt file. Your output should be displayed as given below:
CNIC : 12345-123456-1
Date of Birth : May 1
Student ID: BC00000000 ( Must be same as your own VU ID)
CNIC : 12345-123456-2
Date of Birth : March 1
Student ID: MC00000000
. And lastly, if user enters 3 then exit from the program.
You also have to handle exceptions properly in your program.
Important Regarding Submission:
After completing your code, execute your java file(s) on command prompt and enter students’ records to store them in students.txt file. You must have to provide your own information while entering first student’s record otherwise marks will be deducted accordingly. Students.txt file must contain at least one record (containing your own information i.e. your name, id, study program and etc.). Now, compress your java file(s) and students.txt file using winzip or winrar and upload it on VULMS.
NOTE: Do not put any query on MDB about this assignment, if you have any query then email at firstname.lastname@example.org. Furthermore, if any student found cheating from any other student or from online forums then he/she will be awarded ZERO right away and strict disciplinary action will be taken against the student.
Deadline: Your assignment must be uploaded/submitted on or before 11th May 2018.DOWNLOAD SOLUTION HERE