Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

EDIT: PLEASE ANSWER MY QUESTION I DON'T HAVE MUCH TIME, JUST WRITE A NEW CODE SIMILAR TO MINE IF U WANT! Hey! i've see multiple

EDIT: PLEASE ANSWER MY QUESTION I DON'T HAVE MUCH TIME, JUST WRITE A NEW CODE SIMILAR TO MINE IF U WANT!

Hey! i've see multiple answers to this question but none have met my level that i want(i need much simpler), so here's the question

Write a C++ program(as simple as possible using only struct/classes, setters/getters, pointers, arrays and all the simple stuff (NO libraries/vectors/override)) : Consider that a system has two entities, Student and Course. The student has the following properties: student name, number, SSN 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.

need to implement the following :

  1. In course, the number of students that are registering this course is decided at the time when instantiating the course object.
  2. Need a boolean function to compare 2 students objects and The statement is true if the objects have the same GPA and Name.
  3. Write a getStudentpByName method in class course that takes a student name and returns a list of all students who share the same name.
  4. Write a getStudentByGPA method in class course that takes a GPA and returns a list of Students in that course who have the same GPA.

And most importantly i need also to implement everything in Main and make sure everything works

Now i wrote a code myself(down below) but it's obviously not complete but it has no error. So all is required is branch 2 + check my code and edit it if needed + implementing everything in main(calling branches 2,3,4 in main and show they work properly)

that's all thanks <3

#include #include using namespace std;

class Student{

char name[20]; int stno; int ssn; double gpa; public: Student(){ }

Student (char name[],int stno,int s, double g){

strcpy(this->name,name); this->stno=stno; this->ssn=s; //optional this->gpa=g; //optional } char *getName(){ return name; }

void setName(char n[]){ strcpy(name,n); } void setStno(int i){ stno=i; }

int getStno(){ return stno; } void setSsn(int s){ ssn=s; }

int getSsn(){ return ssn; } void setGPA(double g){ gpa=g; }

double getGPA(){ return gpa; }

};

class Course { char cname[20]; int cno; int CH; Student *s; int n; public:

Course(char cname[],int cno,int CH, int n){

strcpy(this->cname,cname);

this->cno=cno;

s=new Student [n];

char sname[20]; int stno;int ssn; double gpa;

for (int i=1;i<=n;i++){

cout <<"Enter values for student #"<

cin>>sname>>stno>>ssn>>gpa;

s[i].setName(sname); s[i].setStno(stno); s[i].setSsn(ssn); s[i].setGPA(gpa);

} }

char *getName(){ return cname; }

void setName(char n[]){ strcpy(cname,n); }

void setCno(int c){ cno=c; }

int getCno(){ return cno; } void setCH(int d){ CH=d; }

int getCH(){ return CH; } Student * getStudent(){ return s; }

void setStudent(char sname[], int sno,int ssn, double gpa){ delete s; s = new Student(sname,sno,ssn,gpa); } Student *getStudentByName(char *n1){ int c=0; Student *ar; for (int i=0;i if(strcmp(s[i].getName(),n1)==0) c++; ar= new Student[c+1]; for (int i=0,j=0;i if(strcmp(s[i].getName(),n1)==0){ ar[j]=s[i]; j++; } return ar; } Student *getStudentByGPA(double g) {

int c=0;

for (int i=0;i

if (s[i].getGPA()>=g)

c++;

Student *temp = new Student[c+1];

int j=0;

for (int i=0;i

if (s[i].getGPA()==g)

temp[j++]=s[i];

Student *ss=new Student("noname",0,0,-1);

temp[j]=*ss;

return temp; } };

int main() { Course c1("CSE",1,3,3);

return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

I'm working on a problem similar to this:...

Answered: 1 week ago

Question

State the importance of motivation

Answered: 1 week ago

Question

Discuss the various steps involved in the process of planning

Answered: 1 week ago

Question

What are the challenges associated with tunneling in urban areas?

Answered: 1 week ago

Question

What are the main differences between rigid and flexible pavements?

Answered: 1 week ago

Question

What is the purpose of a retaining wall, and how is it designed?

Answered: 1 week ago