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

In c++ i must create a GradeBook application(this must have classes - NO CIN in

ID: 3582802 • Letter: I

Question

In c++ i must create a GradeBook application(this must have classes - NO CIN in the Gradebook class).

I need three classes, one for gradebook, one for students, and one for grade categories.

Grade book should allow user to enter as many categories as they want and weights ( example: user can enter "final", "attendence', "homework" as categories).

if weight doesn't add up to 100%, throw an exception

List of students - list of scores per category(score 0 - 100 points for the category)

List of categories - category name and percentage weight.

When entering student name, if it isn't in the list, add it - otherwise update scores

Enter grades by student - then by category, prompt for score for each category

looping menu :

Grade Book should be able to return class average(final score)

return averages score for each category

given a student, return string individual student scores by category and final score.

I must also use vectors, not arrays, to store memory lists for the students, grades, categories, etc.

Explanation / Answer

#include <iostream>
#include <string>
using namespace std;
struct GradeBook
{
   string name;      
   int* tests;          
   double average;      
   char grade;          
};
int inputStudents();              
int inputTests();                  
int inputName();                  
int *inputScores(int);              
double calcAverage(int*, int);      
char calcGrade(double);              
void display(GradeBook*, int);      
int counter = 0;                      
string name;

int main()
{
   GradeBook *studentList;
   int size = inputStudents();
   studentList = new GradeBook[size];
if (studentList == NULL)
{
       cout << "Memory Allocation Error!";
       //system("Pause");
       return 0;
   }
   int numOfTests = 3;   //inputTests();

   for (int count = 0; count < size; count++)
   {
       studentList[count].tests = inputScores(numOfTests);
       studentList[count].average = calcAverage(studentList[count].tests, numOfTests);
       studentList[count].grade = calcGrade(studentList[count].average);
   }
   display(studentList, size);

   delete [] studentList;

   //system ("Pause");
   return 0;
}
int inputStudents()
{

   int students;
    counter = inputName();
    students = counter;

   return students;
}
int inputName()
{

   if (name == "Quit")
       return counter;
      
   else while (name != "Quit")
          {
          cout << "Enter the student's name: ";                                               //sldkjf;sklafjskl;jfjkl
          cin >> name;
          ++counter;
          }

   return counter;

}
int *inputScores(int numOfTests)
{

   int *scores;
   scores = new int[numOfTests];

   cout << "Enter the test scores for the student. Press ENTER after each score." << endl;

   for (int count = 0; count < numOfTests; count++){
       cout << "Score " << (count + 1) << ": ";
       cin >> scores[count];
   }

   return scores;
}
double calcAverage(int *testScores, int numOfTests)
{

   int total = 0;
   double average;

   for (int count = 0; count < numOfTests; count++)
   {
       total += testScores[count];
   }
  
   average = total/numOfTests;
   return average;

}
char calcGrade(double average)
{

   char letterGrade;

   if(average > 90 && average <= 100)
       letterGrade = 'A';
   else if (average > 80 && average <= 90)
       letterGrade = 'B';
   else if (average > 70 && average <= 80)
       letterGrade = 'C';
   else if (average > 60 && average <= 70)
       letterGrade = 'D';
   else if (average >= 0 && average <= 60)
       letterGrade = 'F';
   else{
       cout << "Logic error." << endl;
       //exit(1);
   }
   return letterGrade;
}

void display(GradeBook *studentList, int size)
{

   for (int count = 0; count < size; count++)
   cout << studentList[count].name << " " << " " << studentList[count].average << " " << studentList[count].grade << endl;

   return;
}

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