Modify class GradeBook (GradeBook.cpp, and GradeBook.h) (attached) as follows: a
ID: 3744171 • 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).
The CISP400V10A1.exe file is an executable file. You can double click the file to get to the expecting result of this assignment. The GradeBook.h and GradeBook.cpp are bases for you for this program. So, you don’t need to start from scratch but please remove all the non-related information for this assignment. The CISP400V10A1.cpp is a driver program for you to test the required assignment implementation
Put the your (modified or completed) GradeBook.h , GradeBook.cpp and CISP400V10A1.cpp(attached) file in a project you can compile the project and run to the following result. Please be awarded that you can adjust only your program (GradeBook.h , GradeBook.cpp) to generate the required result.
Please modify the following code:
//CISP400V10A1.cpp
// Test program for modified GradeBook class.
#include
using std::cout;
using std::endl;
// 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
// 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
CISP400V10A1.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
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 course name
std::string getInstructorName() const; // gets the course name
void displayMessage() const; // displays a welcome message
private:
std::string courseName; // course name for this GradeBook
std::string professorName; // course name for this GradeBook
}; // end class GradeBook
GradeBook.cpp
#include "GradeBook.h"
// constructor initialize courseName
GradeBook::GradeBook(std::string cName, std::string pName) {
courseName = cName;
professorName = pName;
}
// sets the course name
void GradeBook::setCourseName(std::string cName) {
courseName = cName;
}
// gets the course name
std::string GradeBook::getCourseName() const {
return courseName;
}
// sets the professor name
void GradeBook::setInstructorName(std::string pName) {
professorName = pName;
}
// gets the professor name
std::string GradeBook::getInstructorName() const {
return professorName;
}
// displays a welcome message
void GradeBook::displayMessage() const {
cout << "********** Welcome To "<<courseName<<" Console Application **********" << endl << endl;
cout << "This course is presented by: " <<professorName<< endl<<endl;
}
---------------------------------------------------------------
Output
Sac state grade book instructor name is: Professor Monks
new Sac state grade book instructor name is: Professor Huang
********** Welcome To Course 500 Console Application **********
This course is presented by: Professor Huang
Press any key to continue . . .
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.