Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement the three member functions specified in student.hpp. You need to fill in the implementations in student.cpp: 1.Student(const char initId[], double gpa) Implement the constructor

Implement the three member functions specified in student.hpp. You need to fill in the implementations in student.cpp:

1.Student(const char initId[], double gpa)

Implement the constructor with arguments. This function will initialize a newly created student object with the passed in values.

2.bool isLessThanByID(const Student& aStudent)

This function will compare the id of the current student object with the passed in one. Return true if id is less than aStudent.id. Otherwise return false.

3.bool isLessThanByGpa(const Student& aStudent)

the above function will compare the gpa of the current student object with the gpa of the passed in one. Return true if gpa is less than aStudent.gpa. Otherwise return false.

4.app.cpp is used to test your code and contains the main function.

5.You can build the app using the make utility, which is supported by the file named Makefile provided in the directory.

--------------------------------------------------------------------

//student.hpp

#ifndef STUDENT_HPP

#define STUDENT_HPP

#include

using namespace std;

class Student

{

public:

Student(const char initId[], double initGpa); // Constructor with arguments.

bool isLessThanByID(const Student& aStudent) const;

bool isLessThanByGpa(const Student& aStudent) const;

void print()const;

private:

const static int MAX_CHAR = 100;

char id[MAX_CHAR];

double gpa;

};

#endif

------------------------------------------------------------------

//app.cpp

// Lab 4 app.cpp

// This is the driver for the member functions in student.cpp.

#include "student.hpp"

int main()

{

Student s1("G10", 3.9); // Testing your constructor with arguments.

Student s2("G20", 3.5);

s1.print();

s2.print();

if(s1.isLessThanByID(s2)) // Testing your isLessThanByID code.

{

cout << "Great job on less than by ID!" << endl;

}

else

{

cout << "Hmm, your less than by ID code is not quite right." << endl;

}

if(s2.isLessThanByGpa(s1)) // Testing your isLessThanByGPA code.

{

cout << "Great job on less than by gpa!" << endl;

}

else

{

cout << "Hmm, your is less than by gpa code is not quite right." << endl;

}

return 0;

}

-----------------------------------------------------------------------

//student.cpp

// Lab 4 student.cpp

#include "student.hpp"

//implement the required 3 functions here

// For the constructor and isLessThanByID, you will need the

// library for strcmp() and strncpy().

void Student::print() const

{

cout << id << '\t' << gpa << endl;

}

-------------------------------------------------------------

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Access Patterns Database Interactions In Object Oriented Applications

Authors: Clifton Nock

1st Edition

0321555627, 978-0321555625

More Books

Students also viewed these Databases questions

Question

Explain the chemical properties of acids with examples.

Answered: 1 week ago

Question

Write the properties of Group theory.

Answered: 1 week ago

Question

How do Dimensional Database Models differ from Relational Models?

Answered: 1 week ago

Question

What type of processing do Relational Databases support?

Answered: 1 week ago

Question

Describe several aggregation operators.

Answered: 1 week ago