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

An instructor would like a program to help her grade student presentations using

ID: 3565153 • Letter: A

Question

An instructor would like a program to help her grade student presentations using peer evaluations. For each presentation, all the other students submit two scores in the range from 0 to 10: one for the content and one for presentation skills. The program takes each set of scores, drops the highest score and the lowest score and finds the average of the remainder. The two averages are printed out, and the overall grade is calculated using 60% weight for the content score and 40% weight for the presentation skills score. This will be repeated for each student presentation.

The program starts out by asking for and reading in N, the number of student evaluators. It then will ask for and read in a student ID, a first name and a last name. The user should then input N integer scores (in the range 0 to 10) for the content, and another N integer scores (in the range 0 to 10) for the presentation skills and store them in two separate arrays. The actual calculation of the average with the highest and lowest scores dropped should be done by a function called average that takes as arguments the number of scores N, and an array with N integer scores. Note that the function will be called twice, once with the content scores and once with the presentation skills scores. The averages returned should be printed out, and the program calculates and prints the overall grade for the student. The overall grade for each student is saved. This should be repeated until a negative number is entered for a student ID.

The program should then print a well formatted table giving the last name, first name, ID, and overall grade of each student. The table should be sorted alphabetically by the last names of the students. The number of presentations and the average overall grade should be printed out below the table.

The instructor would also like a histogram of the overall grades to be printed. To do this, use an array called rangeCounts of size 10. rangeCounts[0] should hold how many grades were less than 1, rangeCounts[1] should hold how many grades were at least 1 but less than 2, etc. rangeCounts[9] should hold the number of grades in the range 9 and above. The program will use rangeCounts to print a histogram by printing one * for each grade in a particular range.

For example, if rangeCounts had the following values:

0    1   2    3   4    5   6    7   8    9

1

2

1

1

0

3

3

6

5

3

then the program would print the following:

Histogram

< 1 *

< 2 **

< 3 *   

< 4 *

< 5       

< 6 ***

< 7 ***

< 8 ******

< 9 *****

>=9 ***

1

2

1

1

0

3

3

6

5

3

Explanation / Answer

#include<iostream>

#include<vector>

#include<iomanip>

using namespace std;

int Partition(int* a, int beg, int end){          //Function to Find Pivot Point-for Quick Sort

    int p=beg, pivot=a[beg], loc;

    for(loc=beg+1;loc<=end;loc++){

                                  if(pivot>a[loc]){

                                                   a[p]=a[loc];

                                                   a[loc]=a[p+1];

                                                   a[p+1]=pivot;

                                                   p=p+1;

                                  }

    }

    return p;

}

void QuickSort(int* a, int beg, int end){          //Quick Sort

     if(beg<end){

                 int p=Partition(a,beg,end);       //Calling Procedure to Find Pivot

                 QuickSort(a,beg,p-1);             //Calls Itself (Recursion)

                 QuickSort(a,p+1,end);             //Calls Itself (Recursion)

     }

}

double average(int n, int *a){                     //function that returns average when an integer array is passed

       QuickSort(a, 0, n-1);                       //first array is sorted

       int sum=0;

       for(int i=1;i<n-1;i++){                     //loop leaving first and last element(ignoring largest and least value)

               sum+=a[i];                          //add sum of all other scores

       }

       double avg = (double) sum/(n-2);            //find average

       return avg;                                 //return the calculated average

}

void printHist(int a[]){                           //function that prints histogram

     //string array to store all histogram relations

     string rel[]={"<1","<2","<3","<4","<5","<6","<7","<8","<9",">=9"};

     cout<<endl<<"Histogram"<<endl;

     for(int i=0;i<10;i++){

             cout<<rel[i]<<" ";

             for(int j=1;j<=a[i];j++)               //print *

                     cout<<"*";

             cout<<endl;

     }

}

int main(){                                         //main function

    int n;                                          //number of evaluators

    int rangeCounts[10]={0};                        //count each range of grades

    string first, last;

    int id;

    double sumGrade=0.0;

    cout << "Please enter the number of student evaluators(N) : ";

    cin >> n;

    vector<int> ids;                                  //vestors to store id, name and grades

    vector<string> fnames;

    vector<string> lnames;

    vector<double> grades;

    while(true){                                      //loop runs infinitely

                cout << "Enter the student ID (-ve to exit) : ";

                cin >> id;

                if(id < 0)                         //loop exis when id entered is -ve

                          break;

                int *cont = new int[n];

                int *pres = new int[n];

                cout << "Enter first name : ";

                cin >> first;

                cout << "Enter last name : ";

                cin >> last;

                cout << "Enter "<<n<<" scores between 0 and 9 for the content of presentation."<<endl;

                for(int i=0;i<n;i++){                   //enter score

                        cout << "Score "<<(i+1)<<" : ";

                        cin >> cont[i];

                }

                cout << "Enter "<<n<<" scores between 0 and 9 for presenation skills."<<endl;

                for(int i=0;i<n;i++){                   //enter score

                        cout << "Score "<<(i+1)<<" : ";

                        cin >> pres[i];

                }

                double avgcon = average(n, cont);    //get average of content score

                double avgpre = average(n, pres);    //get average of presentation skills score

               double grade = (0.6 * avgcon) + (0.4 * avgpre);    //calculate final grade

                cout << "Average of content score : " << avgcon << endl;

                cout << "Average of presenation skills score : " << avgpre << endl;

                cout << "Overall grade : " << grade << endl;

                sumGrade+=grade;                    /*add every grade awarded till now, used to calculate average grade later on*/

                ids.push_back(id);                  //push id, name and grade into respective vectors

                fnames.push_back(first);

                lnames.push_back(last);

                grades.push_back(grade);

                if(grade<1.0)                       //increment range count based on value of grade

                             ++rangeCounts[0];

                else if(grade<2.0)

                                  ++rangeCounts[1];

                else if(grade<3.0)

                                  ++rangeCounts[2];

                else if(grade<4.0)

                                  ++rangeCounts[3];

                else if(grade<5.0)

                                  ++rangeCounts[4];

                else if(grade<6.0)

                                  ++rangeCounts[5];

                else if(grade<7.0)

                                  ++rangeCounts[6];

                else if(grade<8.0)

                                  ++rangeCounts[7];

                else if(grade<9.0)

                                  ++rangeCounts[8];

                else

                                  ++rangeCounts[9];

    }

    int size=lnames.size();       //size of vector = no of presentations

    int index;

     for(int i=0;i<size-1;i++){   //sort vectors according to last name

            string min=lnames[i];

            index=i;

            string b;

            for(int j=i+1;j<size;j++){

                    b=lnames[j];

                    if(strcmp(b.c_str(),min.c_str())<0){

                                      index=j;

                                      min=lnames[j];

                    }

            }

            if(index!=i){                           //changes made in last name vector are mirrored in all other vectors

                         string temp;

                         int tid;

                         double tgr;

                         temp = lnames[i];

                         lnames[i] = lnames[index];

                         lnames[index] = temp;                    

                         tid = ids[i];

                         ids[i] = ids[index];

                         ids[index] = tid;

                         temp = fnames[i];

                         fnames[i] = fnames[index];

                         fnames[index] = temp;

                         tgr = grades[i];

                         grades[i] = grades[index];

                         grades[index] = tgr;

            }

    }                                  //end of sort

   

    cout<<left<<setw(15)<<"Last Name"<<left<<setw(15)<<"First Name"<<left<<setw(15)<<"Student ID"<<left<<setw(20)<<"Overall Grade"<<endl;

    for(int i=0;i<size;i++){

            cout<<left<<setw(15)<<left<<lnames[i]<<left<<setw(15)<<fnames[i]<<left<<setw(15)<<ids[i]<<left<<setw(20)<<grades[i]<<endl;

    }

    double avgGrade=(double)sumGrade/size;                //calculate average grade, using sum of grade calculated earlier

    cout<<endl<<"No of presentations : "<<size<<endl;

    cout<<endl<<"Average grade : "<<avgGrade<<endl;

    printHist(rangeCounts);                        //call histogram printing function

    system("pause");

}

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