Question: Note: Using Dev C++ .. #include using namespace std; class Student{ string id; string name; int test1_marks; int test2_marks; int finalExam; char grade; public: Student(){
Note: Using Dev C++ ..
#include
class Student{ string id; string name; int test1_marks; int test2_marks; int finalExam; char grade; public: Student(){ id = ""; name = ""; test1_marks = 0; test2_marks = 0; finalExam = 0; grade = '.'; } /***** Question 1 (2 marks) - Write the implementation of mutator/setter method for "id" attribute. *****/ void setId(string id) { this->id = id; } void setName(string name) { this->name = name; } void setTest1_marks(int test1_marks) { this->test1_marks = test1_marks; } void setTest2_marks(int test2_marks) { this->test2_marks = test2_marks; } void setFinalExam(int finalExam) { this->finalExam = finalExam; } void setGrade(char grade) { this->grade = grade; } string getId() { return id; } string getName() { return name; } int getTest1_marks() { return test1_marks; } int getTest2_marks() { return test2_marks; } int getFinalExam() { return finalExam; } char getGrade() { return grade; } /***** Question 2 (2 marks) - Write the implementation of accessor/getter method for "grade" attribute. *****/ };
int calculateCourseWork(Student); char determine_grade(int smarks);
int main() { Student std1 = Student(); Student std2 = Student(); //std1.setId("S1"); // uncomment this statement once you have implemented the setter method for id attribute. std1.setId("S1"); std1.setName("Jim"); std1.setTest1_marks(18); std1.setTest2_marks(25); std1.setFinalExam(30); //std2.setId("S2"); // uncomment this statement once you have implemented the setter method for id attribute. std2.setId("S2"); std2.setName("tom"); std2.setTest1_marks(15); std2.setTest2_marks(25); std2.setFinalExam(45); cout << "Id\tName\tTest1_marks\tTest2_marks\tTest3_marks\tTotal\tGrade " << "``\t````\t```````````\t```````````\t````````````\t`````\t```` "; cout << std1.getId() << "\t" << std1.getName() << "\t" << std1.getTest1_marks() << "\t\t" << std1.getTest2_marks() << "\t\t" << std1.getFinalExam() << "\t\t" << calculateCourseWork(Student(std1)) /***** Question 4 (1 mark) - Call the calculateCourseWork function and pass the first Student object. *****/ << determine_grade(calculateCourseWork(std1)) << endl; cout << std2.getId() << "\t" << std2.getName() << "\t" << std2.getTest1_marks() << "\t\t" << std2.getTest2_marks() << "\t\t" << std2.getFinalExam() << "\t\t" < int calculateCourseWork(Student) { int finalExam; finalExam=Test1_marks+Test2_marks+FinalExam; /***** Question 3 (2 marks) - Write the implementation to calculate and return the CourseWork which is sum of all assessments*****/ } char determine_grade(int mark) { char grade; if (mark >= 80) grade = 'A'; else if(mark >= 65) grade = 'B'; else if(mark >= 50) grade = 'C'; else grade = 'D'; return grade; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
