Question
Implement this code please, and if there were notes alongside this it would be very helpful. I’m using C++ in Microsoft Visual Studio.


Person name : string #emai!Address: string GetName string +GetEmailAddress) string +Person (name:string, emailAddress:string
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<iostream>
#include<conio>
#include<list>
#include<string>

using namespace std;

class Person
{
   public:
   String name="null";
   String emailAddress;
   Person(String a , String b)
   {
   name=a;
   emailAddress=b;
   }
   String GetName()
   {
   return name;
   }
   String GetEmailAddress()
   {
   return emailAddress;
   }

}

class Instructor:public Person
{
   public :
   String employeeID;
   Instructor(String a,String b,String c)
   : Person(a,b)
   {
       employeeID=c;
   }
   String GetEmployeeID()
   {
   return employeeID;
   }
}

class Student : public Person
{
   public :
   String studentID;
   float average=0;
   list <int> grades;

   Student(String n,String e,String id)
   : Person(n,e)
   {
   studentID=id;
   }
   String GetStudentID()
   {
   return studentID;
   }
   float GetAverage()
   {
   return average;
   }
   void AddGrade(int n)
   {
       for(list<int>::iterator i=grades.begin();i!=grades.end();i++)
       {

       }
       grades.insert(i,n);

   }
   void ComputeAverage()
   {
       list<int>::iterator i;
       for(i=grades.begin();i!=grades.end();i++)
       {
           average = average+grades.ElementAt(i);
       }
       average=average/i;
   }

}

class Course
{
public :
   String title;
   Instructor *instructor;
   list<Student> students;

   Course(String t , Instructor *i)
   {
       title=t;
       instructor=i;
   }

   String GetTitle()
   {
   return title;
   }

   Instructor GetInstructor()
   {
   return instructor;
   }

   list<Student> GetStudents()
   {
   return students;
   }

   void AddStudent(Student stud)
   {
       for(list<int>::iterator i=students.begin();i!=students.end();i++)
       {
       }
       students.insert(i,stud);
   }
}

COMMENT DOWN FOR ANY QUERY

PLEASE GIVE A THUMBS UP

Add a comment
Know the answer?
Add Answer to:
Implement this code please, and if there were notes alongside this it would be very helpful....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • java programming how would i modify the code below to add a GUI (with a main menu with graphics and buttons, etc...) and include an option to print a list of all students added in a grid format and sh...

    java programming how would i modify the code below to add a GUI (with a main menu with graphics and buttons, etc...) and include an option to print a list of all students added in a grid format and short by name, course, instructor, and location. ///main public static void main(String[] args) { Scanner in = new Scanner(System.in); ArrayList<Student>students = new ArrayList<>(); int choice; while(true) { displayMenu(); choice = in.nextInt(); switch(choice) { case 1: in.nextLine(); System.out.println("Enter Student Name"); String name...

  • In this exercise, we will be refactoring a working program. Code refactoring is a process to...

    In this exercise, we will be refactoring a working program. Code refactoring is a process to improve an existing code in term of its internal structure without changing its external behavior. In this particular example, we have three classes Course, Student, Instructor in addition to Main. All classes are well documented. Read through them to understand their structure. In brief, Course models a course that has a title, max capacity an instructor and students. Instructor models a course instructor who...

  • Hi, I am writing Java code and I am having a trouble working it out. The...

    Hi, I am writing Java code and I am having a trouble working it out. The instructions can be found below, and the code. Thanks. Instructions Here are the methods needed for CIS425_Student: Constructor: public CIS425_Student( String id, String name, int num_exams ) Create an int array exams[num_exams] which will hold all exam grades for a student Save num_exams for later error checking public boolean addGrade( int exam, int grade ) Save a grade in the exams[ ] array at...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT