Code In Java NetBeans
A University wishes to keep information on its students. The proposed Student class has the following instance variables: studentNo: String, studentName: String, dateOfBirth: Date, meritPoints: Integer. Merit Points represents the entry qualification achieved by a student, which is a number between 20 and 200. A class variable is also required, called noOfStudents, which will be incremented each time a Student instance is created. Write Java code to perform the following:
Q : The Student class is extended by two sub classes Undergraduate with an additional attribute testScore, and Postgraduate with an additional attribute GPA. Both the classes implement a calculateMerit() method that returns the overall merit of the student. The undergraduate merit is calculated by adding the test score to the merit points, while for the postgraduate GPA is added to the merit points. The sub classes’ constructor should invoke the super class’s constructor and the sub classes’ toString method should invoke the super class’s toString method.
A) Use enhanced for loop to display the content of each object.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here