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

Modify class GradeBook (GradeBook.cpp, and GradeBook.h) (attached) as follows: a

ID: 3744312 • Letter: M

Question

Modify class GradeBook (GradeBook.cpp, and GradeBook.h) (attached) as follows:

a) Include a second private data member instructorName in the GradeBook class. It represents the course instructor’s name. The data type of the instructorName is a string.

b) Create a new setInstructorName function in the GradeBook class. The function sets the instructor name. It accepts a string argument and does not return anything.

c) Create a new getInstructorName function in the GradeBook class. The function retrieves the instructor name. It does not accept any argument and returns one string data.

d) Modify the constructor to accept two parameters—one for the course name and one for the instructor’s name.

e) Modify member function displayMessage such that it will display the welcome message and course name, then outputs "This course is presented by: " followed by the instructor’s name.

f) Adjust all the necessary statements in the GradeBook.cpp file to display the required space(s) and line space(s).

Please modify the following code:

// GradeBook.cpp
// GradeBook member-function definitions. This file contains
// implementations of the member functions prototyped in GradeBook.h.
#include <iostream>
#include "GradeBook.h" // include definition of class GradeBook
using namespace std;

// constructor initializes courseName with string supplied as argument
GradeBook::GradeBook( string name )
: courseName( name ) // member initializer to initialize courseName
{   
// empty body
} // end GradeBook constructor

// function to set the course name
void GradeBook::setCourseName( string name )
{
courseName = name; // store the course name in the object
} // end function setCourseName

// function to get the course name
string GradeBook::getCourseName() const
{
return courseName; // return object's courseName
} // end function getCourseName

// display a welcome message to the GradeBook user
void GradeBook::displayMessage() const
{
// call getCourseName to get the courseName
cout << "Welcome to the grade book for " << getCourseName()
<< "!" << endl;
} // end function displayMessage

// gradebook. h file

/ GradeBook.h
// GradeBook class definition. This file presents GradeBook's public
// interface without revealing the implementations of GradeBook's member
// functions, which are defined in GradeBook.cpp.
#include <string> // class GradeBook uses C++ standard string class

// GradeBook class definition
class GradeBook
{
public:
explicit GradeBook( std::string ); // constructor initialize courseName
void setCourseName( std::string ); // sets the course name
std::string getCourseName() const; // gets the course name
void displayMessage() const; // displays a welcome message
private:
std::string courseName; // course name for this GradeBook
}; // end class GradeBook  

Explanation / Answer

ScreenShot

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

Program

GradeBook.h

#pragma once
#include<string>
#include<iostream>
using namespace std;
class GradeBook
{
public:
   explicit GradeBook(std::string, std::string); // constructor initialize courseName
   void setCourseName(std::string); // sets the course name
   std::string getCourseName() const; // gets the course name
   void setInstructorName(std::string); // sets the instructor name
   std::string getInstructorName() const; // gets the instructorname
   void displayMessage() const; // displays a welcome message
private:
   std::string courseName; // course name for this GradeBook
   std::string instructorName; // instructor name for this GradeBook
}; // end class GradeBook

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

GradeBook.cpp

// GradeBook.cpp
// GradeBook member-function definitions. This file contains
// implementations of the member functions prototyped in GradeBook.h.
#include <iostream>
#include "GradeBook.h" // include definition of class GradeBook
using namespace std;

// constructor initializes courseName with string supplied as argument
GradeBook::GradeBook(string name, string pname)
  
{
   courseName = name;
   instructorName = pname;
} // end GradeBook constructor

// function to set the course name
void GradeBook::setCourseName(string name)
{
   courseName = name; // store the course name in the object
} // end function setCourseName

// function to get the course name
string GradeBook::getCourseName() const
{
   return courseName; // return object's courseName
} // end function getCourseName
void GradeBook::setInstructorName(string name)
{
   instructorName = name; // store the professor name in the object
} // end function setInstructorName

// function to get the course name
string GradeBook::getInstructorName() const
{
   return instructorName; // return object's professorName
} // end function getInstructorName

// display a welcome message to the GradeBook user
void GradeBook::displayMessage() const
{
   // call getCourseName to get the courseName
   cout << "Welcome to the grade book for " << getCourseName()<< "!" << endl;
   // call getInstructorName to get the professorName
   cout << "This course is presented by: " << getInstructorName() << endl;
} // end function displayMessage

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

Test.cpp

// include definition of class GradeBook from GradeBook.h
#include "GradeBook.h"

// function main begins program execution
int main()
{
   // create a GradeBook object; pass a course name and instructor name
   GradeBook gradeBook("Course 500", "Professor Monks");

   // display initial value of instructorName of GradeBook object
   cout << " Sac state grade book instructor name is: "
       << gradeBook.getInstructorName() << " ";

   // modify the instructorName using set function
   gradeBook.setInstructorName("Professor Huang");

   // display new value of instructorName
   cout << " new Sac state grade book instructor name is: "
       << gradeBook.getInstructorName() << " ";

   // display welcome message and instructor's name
   gradeBook.displayMessage();
   system("PAUSE");

   return 0; // indicate successful termination
} // end main


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

Output

Sac state grade book instructor name is: Professor Monks

new Sac state grade book instructor name is: Professor Huang

Welcome to the grade book for
Course 500!
This course is presented by: Professor Huang
Press any key to continue . . .

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