c++
Fix the code to work as in the image using char array
dont use fflush(stdin); // clear the buffer and #include
#include class Student{ char name[25],address[30]; int SSN; double gpa; public: Student(){ } Student (char name[],int SSN,char address[], double g){ strcpy(this->name,name); strcpy(this->address,address); this->SSN=SSN; this->gpa=g; } char *getName(){ return name; } void setName(char n[]){ strcpy(name,n); } char *getAddress(){ return address; } void setAddress(char n1[]){ strcpy(address,n1); } void setGPA(double g){ gpa=g; } double getGPA(){ return gpa; } void setSSN(int i){ SSN=i; } int getSSN(){ return SSN; } }; class course{ char courseName[30]; int courseNumber; int creditHours; Student *st; int num_students; public: int n5; course(char courseName[],int courseNumber,int creditHours){ strcpy(this->courseName,courseName); this->courseNumber=courseNumber; this->creditHours=creditHours; } char *getcourseName(){ return courseName; } void setcourseName( char n3[]){ strcpy(courseName,n3); } void setcourseNumber(int f){ courseNumber=f; } int getcourseNumber(){ return courseNumber; } void setcreditHours(int b){ creditHours=b; } int getcreditHours(){
return creditHours; } }; class Department { char dname[10],daddress[30]; int dssn; Student *s; course *sd; public: Department(char dname[],int dssn, char sname[], int sssn,char sdaddress[], double gpa){ strcpy(this->dname,dname); strcpy(this->daddress,daddress); this->dssn=dssn; s=new Student (sname,sssn,sdaddress,gpa); } char *getName(){ return dname; } void setName(char n[]){ strcpy(dname,n); } char *getAddress(){ return daddress; } void setAddress(char n1[]){ strcpy(daddress,n1); } void setSSN(int d){ dssn=d; } int getSSN(){ return dssn; } Student * getStudent(){ return s; } void setStudent(char sname[], int sno,char daddress[], double gpa){ delete s; s = new Student(sname,sno,daddress,gpa); } };
class Department2 { char dname[25],daddress[30]; int dno; Student *s; course *sd; char courseName[30]; int courseNumber; int creditHours; int n; public: Department2(char dname[],int dssn,char daddress[], int n){ strcpy(this->dname,dname); strcpy(this->daddress,daddress); this->dno=dno; cout>n; s=new Student [n]; char sname[20],sdaddress[30]; int sssn; double gpa; for (int i=1;i>sname>>sssn>>daddress>>gpa;
s[i].setName(sname);
s[i].setGPA(gpa); s[i].setAddress(sdaddress); s[i].setSSN(sssn); } } Department2(char courseName[],int courseNumber,int creditHours){ strcpy(this->courseName,courseName); this->courseNumber=courseNumber; this->creditHours=creditHours; sd=new course[n]; char sname[20],sdaddress[30]; int sssn; double gpa; for (int i=1;i>courseName>>courseNumber>>creditHours; sd[i].setcourseName(sname); sd[i].setcourseNumber(gpa); sd[i].creditHours(sdaddress); } } char *getcourseName(){ return courseName; } void setcourseName( char n3[]){ strcpy(courseName,n3); } void setcourseNumber(int f){ courseNumber=f; } int getcourseNumber(){ return courseNumber; } void setcreditHours(int b){ creditHours=b; } int getcreditHours(){
return creditHours; }
void setcourses(char dcourseName[],int dcourseNumber,int dcreditHours){ delete sd; sd = new course(dcourseName,dcourseNumber,dcreditHours); } } char *getName(){ return dname; } void setName(char n[]){ strcpy(dname,n); } char *getAddress(){ return daddress; } void setAddress(char n1[]){ strcpy(daddress,n1); } void setSSN(int d){ dno=d; } int getSSN(){
return dno; } Student * getStudent(){ return s; } void setStudent(char sname[], int sno,char daddress[], double gpa){ delete s; s = new Student(sname,sno,daddress,gpa); } Student * getStudentByGPA(double g) { int c=0; for (int i=0;i>g; s[i].setGPA(g); } for (int i=0;i=g) c++; Student *temp = new Student[c+1]; int j=0; for (int i=0;i=g) temp[j++]=s[i]; Student *ss=new Student("noname",0,"noaddress",-1); temp[j]=*ss; return temp; } Student * getStudentpByAddress(char sdaddress) { int c=0; for (int i=0;i>daddress; s[i].setAddress(daddress); } for (int i=0;i=daddress) temp[j++]=s[i]; Student *ss=new Student("noname",0,"noaddress",-1); temp[j]=*ss; return temp; } bool equal(){ char nam[30]; for(int i=0;i main(){ Department2 d1("mahmud",1,"jenin",3);
}
Consider that a system has two entities, Student and Course. The student has the following properties: student name, SSN, address and GPA. Similarly, the course has the following properties: course name, course number, credit hours and a set of students who .are currently registering on the course Implement the above system taking into account the following requirements In course, the number of students that are .1 registering this course is decided at the time when [instantiating the course object. [2 marks Assume that student1 and student2 are two objects .2 of type student, write a code that enables you to write: if (student1.isequal (student2)). Where studenti, student12 are student objects. The statement is true if the objects have the same address and name. [2 [marks Write a getStudentpByAddress method in class.3 course that takes a student's Address and returns a list of all students who have the same address. [3 [marks Write a getStudentByGPA(double .4 GPA_Student) method in class course that takes a GPA and returns a list of Students who have GPA [above the received GPA_Student.[3 marks Consider that a system has two entities, Student and Course. The student has the following properties: student name, SSN, address and GPA. Similarly, the course has the following properties: course name, course number, credit hours and a set of students who .are currently registering on the course Implement the above system taking into account the following requirements In course, the number of students that are .1 registering this course is decided at the time when [instantiating the course object. [2 marks Assume that student1 and student2 are two objects .2 of type student, write a code that enables you to write: if (student1.isequal (student2)). Where studenti, student12 are student objects. The statement is true if the objects have the same address and name. [2 [marks Write a getStudentpByAddress method in class.3 course that takes a student's Address and returns a list of all students who have the same address. [3 [marks Write a getStudentByGPA(double .4 GPA_Student) method in class course that takes a GPA and returns a list of Students who have GPA [above the received GPA_Student.[3 marks<><><><><><>