A class named Person having A protected attribute name as string. A protected attribute cnic as int. A private attribute address as string A private attribute fatherName as string. A parametrized constructor that assigns provided values to all the attributes. A Teacher class that is-a Person as well, has A private attribute Id. A parametrized constructor that assigns Id, name, cnic, address, fatherName. (You should call super constructor to assign values for Person) A class named Course has A private attribute String courseName A private attribute Teacher teacher A private attribute double marks. (min: 0 and max 100) A private attribute int creditHours A private attribute char grade A private attribute double GPA A parameterized constructor to initialize attributes courseName, creditHours and marks, this constructor should also calculate grade and GPA, according to the grading policy defined in table below: Latter Grade Percentage Gpa A 80-100 4 B 70-75 3 C 60-69 2 D 50-59 1 F <50 0 A getter getCourseName() function that will return courseName of the course. A getter getGPA() function that will return GPA of the course.
A class named Person having
A protected attribute name as string.
A protected attribute cnic as int.
A private attribute address as string
A private attribute fatherName as string.
A parametrized constructor that assigns provided values to all the attributes.
A Teacher class that is-a Person as well, has
A private attribute Id.
A parametrized constructor that assigns Id, name, cnic, address, fatherName. (You should call super constructor to assign values for Person)
A class named Course has
A private attribute String courseName
A private attribute Teacher teacher
A private attribute double marks. (min: 0 and max 100)
A private attribute int creditHours
A private attribute char grade
A private attribute double GPA
A parameterized constructor to initialize attributes courseName, creditHours and marks, this constructor should also calculate grade and GPA, according to the grading policy defined in table below:
Latter Grade | Percentage | Gpa |
A | 80-100 | 4 |
B | 70-75 | 3 |
C | 60-69 | 2 |
D | 50-59 | 1 |
F | <50 | 0 |
A getter getCourseName() function that will return courseName of the course.
A getter getGPA() function that will return GPA of the course.
A getter getCreditHours() function that will return creditHours of the course.
A class name Semester
A private attribute SemesterNumer as int (1 to 8, according to students’ progress, he may repeat the same semester many times)
A private attribute Double SGPA
A private attribute semesterCreditHours
A private attribute string result (Pass or Fail) A private attribute ArrayList<Course> courses (2 courses)
A parameterized constructor that gets semesterNumber and two courses as parameters of that semester and it will set the value of result as “Pass” or “Fail”.
If one of the courses has F grade the semester result is set to “Fail”.
It will also set semesterCreditHours by adding creditHours of both courses. It will also calculate the SGPA
A Student class that is-a Person as well, has A Private attribute sapid as int
A Private totalcreditHours as int
A private double attribute CGPA
A Private ArrayList<Semester> semesters, containing information of all the semesters.
A default constructor that assigns default values.
A parameterized constructor that takes only sapid, name, cnic, address, fatherName sets the value of respective attributes and initializes semesters with a new empty ArrayList.
A public method addSemester(semester Semester), that adds a semester in semesters ArrayList.
A public method calculateCGPA(), to calculate the overall CGPA of all the semesters that are passed so far.
Override toString () method that will return the result of all the semesters as a String in the following format: Result of Ahmad Khan: CGPA = 3.5, Credits Earned = 14
Semester 1: Computer Fundamentals: GPA{ 3 }, Grade { B }, CreditHours{ 3 } Calculus: GPA { 3 }, Grade { B }, CreditHours { 3 } SGPA: 3.00
Semester 2: OOP: GPA{ 4 }, Grade { A }, CreditHours{ 4 } Software Engineering: GPA { 4 }, Grade { A }, CreditHours { 4 } SGPA: 4 A public method printTranscript() that will simply store the string returned by toString() method to a file.
Write a main() method to test your code. Sample testing code is provided below. You should test other possible cases too.
Course cl = new Course ("Programming Fundamentals", 3, 68);
Course c2 = new Course ("Islamic Studies", 2, 55);
Course c3 = new Course ("0OP", 4, 90);
Course c4 = new Course ("Software Engineering", 3, 75);
Semester sl = new Semester (1, cl,c2);
Semester s2 = new Semester (2, c3,c4);
Student s = new Student (13590, "Ahmad Khan", 134564564564, "Street4, I-14,Islamabad", "Ali Khan");
s.addSemester (sl);
s.addSemester (s2); //check if string is building correctly System.out.println (s.toString ()); //print to file s.printTranscript (); END
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images