Make a project, consisting of 3 modules: student.cpp, course.cpp and register.cpp. Write source and header file for a program that registers students for courses. Design a class student, that stores the name of the student , the id number and array(vector) of all course numbers for which the student is resisted. Design a class course that stores the course number, and array(vector) of the id numbers of all students who are registered for this course. In the register.cpp implement functions that add and drop students and print course lists.

so that's what i have so far but i don't know how to do the print function for this program. can anybody code that for me plz so i would know for the next time.

thank you guys ur doing a great job love this website..

#include <iostream>

#include <string>

#include <vector>

using namespace std; 

class student

{

public:

      student() {};

    student(string studentName,int studentID);

    int  get_id();

    void addCourse (int courseNumber);

    void dropCourse (int courseNumber);

    void print();

    friend class course; 

private:

    int studentID;

    string studentName;

    vector<int> courseID;

}; 

student::student(string n,int ID)

{

      studentID=ID;

      studentName=n;

} 

int student::get_id()

{

      return studentID;

} 

void student:: addCourse (int courseNumber)

{

    courseID.push_back (courseNumber);

}

void student::dropCourse (int courseNumber)

{

    for (int i = 0; i < (int)courseID.size(); i++)

    {

        if (courseID[i] == courseNumber)

        {

            int temp = courseID[i];

            courseID [i] = courseID [courseID.size()-1];

            courseID [courseID.size()-1] = temp;

            courseID.pop_back();

        }

    }

}

class course

{

private:

      string name;

      int crn;

      vector<string> s_name;

      vector<int> s_id;

      string studentName[35];

      string studentId[35];

public:

      course(){};

      course(string courseID , int course)

      {

            courseID=courseID;

            crn=course;

      };

      string GetName() 

      { 

            return name; 

      }

      int GetCrn() 

      { 

            return crn;

      }

      int AddStudent(int id);

      void DropStudent(string);

      void PrintStudent();

}; 

void student::print()

{

    cout << studentName << studentID <<endl;

    for (int i = 0; i < (int)courseID.size(); i++)

    {

        cout << courseID[i] <<endl;

    }

} 

int course::AddStudent(int id)

{

      name=id;

      return 0; 
 

} 

void main()

{

      int choice = 0;

    student one("student1",1);

    student two("student2",2);

    student three("student3",3);

    course c_one("math",101);

    course c_two("cis",202);

    course c_three("English",303);

    vector<student>s;

    vector<course>c;

    s.push_back(one);

    s.push_back(two);

    s.push_back(three);

    c.push_back(c_one);

    c.push_back(c_two);

    c.push_back(c_three); 

    while(choice!=3)

    {

        cout<<"1.Add course"<<endl;

        cout<<"2.drop course"<<endl;

            cout<<"3.print"<<endl;

        cout<<"4.Exit"<<endl;

        cin>>choice;

        if(choice==1)

        {

            cout<<"Enter student id";

            int s_id;

            cin>>s_id;

            for(int i=0; i< (int)s.size(); i++)

           {

               if(s_id==s[i].get_id())//you will have to add id

               {

                   cout<<"Enter course crn"<<endl;

                   int c_id;

                   cin>>c_id;

                   for(int j=0; j<(int)c.size(); j++)

                   {

                       if(c_id==c[j].GetCrn())

                       {

                           s[i].addCourse(c[j].GetCrn());

                           c[j].AddStudent(s_id);

                                 }

                           }

                     }

                  }

            }

            if(choice==2)

            {

                  cout<<"Enter course id";

                  int c_id;

                  cin>>c_id;

                  for(int i=0;i<(int)s.size();i++)

                  {

                        if(c_id==c[i].GetCrn())

                        {

                              cout<<"student id"<<endl;

                              int s_id;

                              cin>>s_id;

                              for(int j=0; j<(int)c.size(); j++)

                              {

                              s[i].addCourse(c[j].GetCrn());

                              c[j].AddStudent(c_id);

                              }

                        }

                  }

            }

            if(choice==3)

            {

                  cout<<"the se"<<endl;

                  student; 

      }

}

1) Please use code tags
2) Please use a reasonable indention scheme for your braces (maybe not using code tags affected this?)
3) Try to narrow down your question to the smallest piece of code possible. Maybe make a 10 line example that fills a vector and then ask "how do I output all the values in the vector?" or something like that. Abstracting the problem really helps people help you, because many people won't want to read about all these classes (student, course, etc), but they may take 2 seconds to read that you want to output items in a vector. See what I mean?

Dave

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.