Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

First create a student class that contains the name and student ID, set and get

ID: 650322 • Letter: F

Question

First create a student class that contains the name and student ID, set and get functions.

Then create a department class that contains name of department (for example computer science or electric engineering) and set and get functions.

After that create a college class that contains school name and number of departments, an array of 3 departments by using composition and an array of 4 students by using aggregation.

Test them in main by creating a college that has college name and some number of majors, an array of departments, and an array of students. Use set and get functions to get information from the college.(C++)

Explanation / Answer

#include <iostream>
#include <conio.h>
#include <string>

using namespace std;

class student
{

public:
   string name;
   int SID;
  
   void setname(string N)
   {
       this->name = N;
   }
   string getname()
   {
       return name;
   }


   void setSID(int ID)
   {
   this->SID = ID;
   }
   int getSID()
   {
       return SID;
   }
};

class department
{
public:

   string nameofdepartment;

   void setnameofdepartment(string NOD)
   {
   this->nameofdepartment = NOD;
   }
   string getnameofdepartment()
   {
       return nameofdepartment;
   }
};

class college
{
private:
   string schoolname;

public:

   void enrollstudent()
{
   string N;
string NOD;
string SN;
int ID = 0;
int i;

student S[12];
department D[3];
  
cout <<" Enter School Name : ";
cin >> schoolname ;
  
   cout <<"Department number : 1 "<< " ";
   cout <<"Enter Department Name ";
   cin >> NOD;

   D[0].setnameofdepartment(NOD);
  
   for(i=0; i<4; i++)
  
   {
   cout <<"Enter Student Name: ";
   cin >> N;

           S[i].setname(N);

   cout <<"Enter Student ID: ";
   cin >> ID;

           S[i].setSID(ID);
}

   cout <<"Department number : 2 "<< " ";
   cout <<"Enter Department Name ";
   cin >> NOD;

   D[1].setnameofdepartment(NOD);
  
   for(i=4; i<8; i++)
  
   {
   cout <<"Enter Student Name: ";
   cin >> N;

           S[i].setname(N);

   cout <<"Enter Student ID: ";
   cin >> ID;

           S[i].setSID(ID);
}

   cout <<"Department number : 3 "<< " ";
   cout <<"Enter Department Name ";
   cin >> NOD;

   D[2].setnameofdepartment(NOD);
  
   for(i=8; i<12; i++)
  
   {
   cout <<"Enter Student Name: ";
   cin >> N;

           S[i].setname(N);

   cout <<"Enter Student ID: ";
   cin >> ID;

           S[i].setSID(ID);
}

   cout <<" School Name : " << schoolname << " ";

   cout <<" Department number : 1" << " ";
   cout <<" Department Name :" << D[0].getnameofdepartment() << " ";

   for(i=0; i<4; i++)
{
   cout <<" Student Name: " << S[i].getname() << " ";
           cout <<"Student ID: " << S[i].getSID() << " ";
}

   cout <<" Department number : 2" << " ";
   cout <<" Department Name :" << D[1].getnameofdepartment() << " ";

   for(i=4; i<8; i++)
{
   cout <<" Student Name: " << S[i].getname() << " ";
           cout <<"Student ID: " << S[i].getSID() << " ";
}

   cout <<" Department number : 3" << " ";
   cout <<" Department Name :" << D[2].getnameofdepartment() << " ";

   for(i=8; i<12; i++)
{
   cout <<" Student Name: " << S[i].getname() << " ";
           cout <<"Student ID: " << S[i].getSID() << " ";
}
}

};

int main()
{
   college C;
   C.enrollstudent();
return 0;
}