vector

Each student now has 3 raw scores from 3 exams, and their corresponding weights for
grade are 30%, 30% and 40%. Your program need to convert these raw scores individually into curve
scores proportionally adjusted to the highest score in the class for every exam. Then, you would
calculate the total score based on the weight and curve score of each individual exam. Subsequently,
the total score is used to rank the student and determine their final letter grades by favorable grading
policy.
Your program needs to utilize the Standard Template Library (vector, sort, and iterators), so that you no
longer need to have the const maxClassSize for the array of Students. You would utilize the sort
algorithm instead of writing your own sort code. You also need to implement operator overload of
insertion operator < <with ostream and extraction operator >> with ifstream. Besides, your program
should be easily modified to accommodate different number of exams, for example, 5 exams instead of
3 (Use global const to define the number of exams)


> #include <iostream> // for input and output
> #include <iomanip> // for formatting output
> #include <string> // for class string
> #include <fstream> // for file input/output
> #include <cstdlib> // for exit(EXIT_FAILURE)
> using namespace std;
> const int MAXSTUDENT = 100;
> const int BAR = 60;
> enum GRADE { F, D, CMINUS, C, CPLUS, BMINUS, B, BPLUS, AMINUS, A };
> class Student
> {
> private:
> string nameFirst;
> string nameLast;
> double rawScore;
> double percentRank;
> GRADE pointGrade;
> GRADE curveGrade;
> string letterGrade;
>
> public:
> void setFirstName(string s)
> {
> nameFirst = s;
> }
> void setLastName(string s)
> {
> nameLast = s;
> }
> void setRawScore(double s)
> {
> rawScore = s;
> }
> void setPercent(double p)
> {
> percentRank = p;
> }
> void setPointGrade(GRADE g)
> {
> pointGrade = g;
> }
> void setCurveGrade(GRADE g)
> {
> curveGrade = g;
> }
> void setLetterGrade()
> {
> GRADE g;
> if ((rawScore >= BAR) && (curveGrade >= pointGrade))
> g = curveGrade;
> else
> g = pointGrade;
> switch (g)
> {
> case F: letterGrade = "F"; break;
> case D: letterGrade = "D"; break;
> case CMINUS: letterGrade = "C-"; break;
> case C: letterGrade = "C"; break;
> case CPLUS: letterGrade = "C+"; break;
> case BMINUS: letterGrade = "B-"; break;
> case B: letterGrade = "B"; break;
> case BPLUS: letterGrade = "B+"; break;
> case AMINUS: letterGrade = "A-"; break;
> case A: letterGrade = "A"; break;
> }
> }
> string getFirstName()
> {
> return nameFirst;
> }
> string getLastName()
> {
> return nameLast;
> }
> double getRawScore()
> {
> return rawScore;
> }
> double getPercent()
> {
> return percentRank;
> }
> string getLetterGrade()
> {
> return letterGrade;
> }
> bool operator>(const Student& s)
> {
> return rawScore > s.rawScore;
> }
> bool operator>=(const Student& s)
> {
> return rawScore >= s.rawScore;
> }
> bool operator==(const Student& s)
> {
> return rawScore == s.rawScore;
> }
> bool operator<(const Student& s)
> {
> return rawScore < s.rawScore;
> }
> bool operator<=(const Student& s)
> {
> return rawScore <= s.rawScore;
> }
> };
> class Course
> {
> private:
> Student s[MAXSTUDENT];
> int sizeOfClass;
> double maximumScore;
> double minimumScore;
> double scoreAvg;
>






I got some of the code but I need to change the array into a vector and use the curve (x/y)*100/100





I need to change the array into a vector


Student s[MAXSTUDENT]; becomes std:vector<Student> s;

I see you're no longer meant to use
the const maxClassSize
, which suggests you're not meant to set the size of the vector. Accordingly, when you add Student objects to the vector, do it with the vector push_back function.
Topic archived. No new replies allowed.