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

Using C++ Implement the three member functions specified in student.h. It needs

ID: 3918291 • Letter: U

Question

Using C++ Implement the three member functions specified in student.h. It needs to work on both unix and windows and be able to gcc.

STUDENT.H

#ifndef STUDENT_H

#define STUDENT_H

#include <iostream>

using namespace std;

class Student

{

public:

Student(const char initId[], double gpa);

bool isLessThanByID(const Student& aStudent) const;

bool qualifyForHonor(double minGpaForHonor) const;

void print()const;

private:

const static int MAX_CHAR = 100;

char id[MAX_CHAR];

double gpa;

};

#endif

STUDENT.CPP

#include "student.h"

//implement the required 3 functions here

void Student::print() const

{

cout << id << ' ' << gpa << endl;

}

APP.CPP

#include "student.h"

int main()

{

Student s1("G10", 3.9);

Student s2("G20", 3.5);

s1.print();

s2.print();

//write code to test Student::isLessThanByID

//write code to test Student::qualifyForHonor

return 0;

}

member functions specifi Implement the three implementation in student.cpp: ed in student.h. You need to fill in the . Student(const char initId[], double gpa) the above function will initialize a newly created student object with the passed in value . bool isLessThanByID(const Student& aStudent) the above function will compare the current student object with the passed in one by id. bool qualifyForHonor (double minGpaForHonor) the above function will return true if the student's gpa is higher than "minGpaForHonor") app.cpp is used to test your code. You need to fill in the blank to test the above functions you create for Student class.

Explanation / Answer

APP.CPP

#include "student.h"

int main()

{

Student s1("G10", 3.9);

Student s2("G20", 3.5);

s1.print();

s2.print();

cout<<"Less than by ID:"<< s1.isLessThanByID(s2)<<endl;

cout<<"Is S1 qualified :"<< s1.qualifyForHonor(3)<<endl;
cout<<"Is S2 qualified: "<< s2.qualifyForHonor(4);


return 0;

}

Student.cpp

#include "student.h"

Student::Student(const char initId[], double gpa)
{
strcpy(id, initId);
this->gpa = gpa;
}

bool Student::isLessThanByID(const Student& aStudent) const
{
if(strcmp(this->id, aStudent.id) < 0)
return true;
else
return false;
}

bool Student::qualifyForHonor(double minGpaForHonor) const
{
if(gpa > minGpaForHonor)
return true;
else
return false;
}

void Student::print() const

{

cout << id << ' ' << gpa << endl;

}

There is no change in student.h

Output:

Less than by ID:1                                                                                                            

Is S1 qualified :1                                                                                                           

Is S2 qualified: 0

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