Project2 - #include<iostream>...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: #include<iostream> #include<string> #include<fstream> using namespace std; u //the code for Question 2 is initially commented out so you can run this code separately first s class Student { private: int Id; //the identification # of the student int FinalGrade; //the overall grade of the student [0,100] float Grade[4]; //four different test grades, each of which ranges from 0.0 to 25.0 public: void setId(int x) //takes an integer paramter, returns nothing { Id = x; }; void setGrade(float x[4]) //takes a floating array parameter and assigns four elements { //of the input array to Grade[4], and returns nothing for(int count=0;count<4;count++) Grade[count] = x[count]; }; bool operator==(Student x) const //'==' operator overloading of class Student, which { //compares if the FinalGrade of the current student is if (FinalGrade == x.FinalGrade) //equal to the FinalGrade of another student. If yes, return true; //true is returned. Otherwise, false is returned. else return false; } friend class Teacher; //makes class Teacher a friend of class Student }; } class Teacher { private: int Id; //the identification # of the student float Salary; //annual salary public: Student calculateGrade(Student a) //takes an input parameter of class Student and sets the { //grade of this student with the given formula a.FinalGrade = a.Grade[0] + a.Grade[1] + a.Grade[2] + a.Grade[3]; return a; }; }; } int main( ) {...
View Full Document

Page1 / 5

Project2 - #include<iostream>...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online