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

In this program, you will develop a class named Course to store a course’s infor

ID: 3620661 • Letter: I

Question

In this program, you will develop a class named Course to store a course’s information

Course Class: This class maintains information about a course, including a course title, course number, instructor’s name, enrollment, students’ names, and scores. Note that the maximum number of students in a course can’t be more than 5. For each student, the course class can hold two exam scores in addition to the student’s name and ID. The course class also needs to maintain the average of all students and print the statistics of letter grades.

Constructor

Course ()
-Default constructor – Initial course title and instructor’s name should be “UNKNOWN”.
Initial course number and enrollment should be zero.

Course (string title, int number)
- Constructor with course title and course number. Initial instructor’s name and enrollment should be “UNKNOWN” and zero, respectively.

Member Functions

void setInstructor (string name)
- Set the instructor’s name of the course.

bool addStudent (string name, int id)
- Add the given student to the course. If a student with the same id is already in the course, do not add the student to the class. In that case, return false. Otherwise, insert the student information to the course and return true.

bool dropStudent (int id)
- Drop the given student with the id from the course. If a student with the id does not exist in the course, return false. Otherwise, return true.

bool putScores (int id, double mid1, double mid2)
- Update a student’s two exams’ scores. If the student’s id doesn’t exist, it returns false.

<<
Print the content of a course such as its course title, instructor, and average of all students. You also need to print each student’s name, id, average, and letter grade. Any average of 90 or more is an ‘A’, any average of 80 or more (but less than 90) is a ‘B’, any average of 70 or more (but less than 80) is a ‘C’, any average of 60 or more (but less than 70) is a ‘D’, and any average below 60 is a ‘F’. Refer the sample run for the detailed format.


Sample Test Program
Execution Result of Sample Program
---------------------------------------------------
Data Structures (222) Course Report
---------------------------------------------------
Instructor: Dr. Ryan
2 students are enrolled in the course.
1 student dropped the course during the semester.
---------------------------------------------------
Average of all students: 90.00
‘A’ --> 1
‘B’ --> 1
‘C’ --> 0
‘D’ --> 0
‘F’ --> 0
---------------------------------------------------
Individual Record
1000: Tom - 100.00 (A)
3000: Alex - 80.00 (B)
---------------------------------------------------

Explanation / Answer

please rate - thanks hope this is good #include <iostream>
using namespace std;
class course
{friend ostream& operator<<( ostream &output, const course &num );
friend int getcount(double,double,const course &num);
friend char getgrade(int ,const course &num);
private:
     string title;
     int number;
     string instruct;
     int enroll;
     string student[5];
     int id[5];
     double score[5][2];
     double average[5];
     int dropped;
   
public:
course();
course (string t, int n);
void setInstructor (string name);
bool addStudent (string name, int idd);
bool dropStudent (int id);
bool putScores (int idd, double mid1, double mid2);

};

      course::course()
         {title="unknown";
         instruct="unknown";
         number=0;
         enroll=0;
         dropped=0;
         }
      course::course (string t, int n)
          {title=t;
         instruct="unknown";
         number=n;
         enroll=0;
         dropped=0;
         }
void course::setInstructor (string name)
         {instruct=name;
         }
bool course::addStudent (string name, int idd)
       {int i;
       for(i=0;i<enroll;i++)
         {if(idd==id[i])
               return false;
               }
       student[i]=name;
       id[i]=idd;
       enroll++;
       return true;
     }

bool course::dropStudent (int idd)
    {int i,j,k;
       for(i=0;i<enroll;i++)
          if(idd==id[i])
               {for(j=i;j<enroll;j++)
                    {student[j]=student[j+1];
                    id[j]=id[j+1];
                    for(k=0;k<2;k++)
                         score[j][k]=score[j+1][k];
                    average[j]=average[j+1];
                     }
                enroll--;
                dropped++;
                return true;
               }
        return false;
     }
bool course::putScores (int idd, double mid1, double mid2)
    {int i;
     for(i=0;i<enroll;i++)
         {if(idd==id[i])
              {score[i][0]=mid1;
              score[i][1]=mid2;
              average[i]=(mid1+mid2)/2.;
              return true;
              }
          }
     return false;
     }
int getcount(double a,double b,const course &num)
   {int i,n=0;
   for(i=0;i<num.enroll;i++)
         if(num.average[i]>=a&&num.average[i]<=b)
             n++;
   return n;
}
char getgrade(int i,const course &num)
{ if(num.average[i]>=90)
        return 'A';
     else if(num.average[i]>=80)
        return 'B';
       else if(num.average[i]>=70)
        return 'C';
       else if(num.average[i]>=60)
        return 'D';
      else
          return 'F';
          }
ostream& operator<<( ostream &output, const course &num )
{
int j,i;
double total,avg;

output<<num.title<<"("<<num.number<<") Course Report ------------------------- ";
output<<"Instructor: "<<num.instruct<<endl;
output<<num.enroll<<" students are enrolled in the course. ";
output<<num.dropped<<" student dropped the course during the semester. ";
output<<"-------------------------------------- ";
if(num.enroll==0)
     avg=0;
else
   {
    for(i=0;i<num.enroll;i++)
        total+=num.average[i];
     avg=total/num.enroll;
     }
output<<"Average of all students: "<<avg<<endl;
output<<"A --> "<<getcount(90.,100,num)<<endl;
output<<"B --> "<<getcount(80.,89,num)<<endl;
output<<"C --> "<<getcount(70.,79,num)<<endl;
output<<"D --> "<<getcount(60.,69,num)<<endl;
output<<"F --> "<<getcount(0.,59,num)<<endl;
output<<"-------------------------------------- ";
output<<"Individual Record ";
for(i=0;i<num.enroll;i++)
    output<<num.id[i]<<": "<<num.student[i]<<" - "<<num.average[i]<<" ("<<
            getgrade(i,num)<<") ";
return output;
}   
int main()
{course a, b("Data Structures",222);
b.setInstructor("Dr. Ryan");
b.addStudent("Tom",1000);
b.addStudent("Dick",2000);
b.addStudent("Alex",3000);
b.putScores(1000,100,100);
b.putScores(2000,90,92);
b.putScores(3000,75,85);
cout<<b<<endl;
b.dropStudent(2000);
cout<<a<<endl;
cout<<b<<endl;
system("pause");
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote