Question
identify the type of coupling between the Main and Student classes, explain the issues with this type of coupling, and modify the code to achieve
-
identify the type of coupling between the Main and Student classes,
-
explain the issues with this type of coupling, and
-
modify the code to achieve a better type of coupling and explain how your code achieves this enhanced level of coupling.
Class Instructor {
String name;
String ID;
String Rank;
}
Class Student {
String first_name;
String last_name;
String address;
String ID;
String Classification;
int exam1_grade;
int exam2_grade;
public float calculate_student_avg (Student Stud) {
private int exam1 = Stud.exam1_grade;
private int exam2 = Stud.exam2_grade;
float avg = ((exam1 + exam2)/2);
return avg;
}
}
Class main {
public static void main(String[] args) {
Instructor inst = new Instructor();
Student stud2 = new Student();
stud2.exam1_grade =80;
stud2.exam2_grade =100;
float average = inst.calculate_student_avg(stud2);
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started