Hi All,
I am new to this community and new to the programming also. I have been tasked with the program and my problem is that I don't know the operator overloading. So, anyone can help me ?
Develop a Student class that has the following header file:
#ifndef STUDENT_H
#define STUDENT_H
#include
#include
#include
using namespace std;
class Student{
public:
Student();
Student(string name,string surname,int a1, int a2, int test, int exam);
string getName()const;
string getSurname()const;
int getAssignment1Mark()const;
int getAssignment2Mark()const;
int getLabTestMark()const;
int getExamMark()const;
void setAssignment1Mark(int);
void setAssignment2Mark(int);
void setLabTestMark(int);
void setExamMark(int);
bool passed()const;
string getGrade()const;
friend ostream& operator<<(ostream& stream, const Student &);
bool operator<(const Student &)const;
private:
string name;
string surname;
int assignment1Mark;
int assignment2Mark;
int labTestMark;
int examMark;
};
#endif
implement the class, i.e. to develop the implementation file “Student.cpp” that conforms to the following specifications:
(1) The data fields have self explanatory identifiers, and their meaning should be clear from the Introduction.
(2) The “set” functions allow the user to set the assessment task marks within the specified margins, e.g. setExamMark ensures that the examMark is in the appropriate range – from 0 to 50.
(3) The function getGrade() returns the student’s grade, calculated as specified in the Introduction. The rest of the “get” functions simply return the values of the corresponding fields.
(4) The function passed() returns true if this student , has passed the course, and returns false otherwise (see the Introduction).
(5) friend ostream& operator<<(ostream& stream, const Student &) – the function overloads << operator, which allows a Student object information to be output in the following format:
Underwood Scott:
Assignment 1 8
Assignment 2 16
Lab Test 0
Exam 34
Grade P
(6) bool operator<(const Student &student)const – the function overloads < operator, which allows to compare student’s full names lexicographically.
Collapse | Copy Code
The following describes how to calculate the marks and grade:
Lab Test Mark – is an integer from 0 to 10;
Assignment1 Mark – is an integer from 0 to 20;
Assignment2 Mark – is an integer from 0 to 20;
Final exam Mark – is an integer from 0 to 50;
A student passes the course if and only if
(Assignment1 Mark + Assignment2 Mark) >= 20 and (Lab Test Mark + Final Exam Mark) >= 30
Collapse | Copy Code
There are 5 grades, which are calculated according to the following rules:
F – if the Total Mark is less then 40;
MF – if (40 <= Total Mark < 50) or (Total Mark >= 50 but student didn’t pass);
P – if (50 <= Total Mark < 60) and student passed;
C – if (60 <= Total Mark < 70) and student passed;
D – if (70 <= Total Mark < 80) and student passed;
HD – if Total Mark >= 80;