In: Computer Science
C++ Design a class named TermPaper that holds an author's name, the subject of the paper, and an assigned letter grade. Include methods to set the values for each data field and display the values for each data field. Create the class diagram and write the pseudocode that defines the class.
Pseudocode help please
Note: variable names and function names are used arbitrarily. These can be changed according to the user's choice. Please refer to code snippets for a better understanding of comments and indentations.
IDE Used: Dev C++
Program Code
#include <iostream>
#include <string>
using namespace std;
class TermPaper
{
// private member variables
private :
string auth_name;
string paper_sub;
char grade;
// member functions
public :
// to set values
void set_value(string aname, string
psub, char g)
{
auth_name =
aname;
paper_sub =
psub;
grade = g;
}
// to print values
void disp_value()
{
cout<<"\nAuthor Name : "<<auth_name;
cout<<"\nPaper Subject : "<<paper_sub;
cout<<"\nGrade : "<<grade;
}
};
int main()
{
// cretae two objects of TermPaper class
TermPaper tp1, tp2;
// call the functions for each object
tp1.set_value("JK Rowling", "Literature", 'A');
tp1.disp_value();
tp2.set_value("Ruskin bond", "Fiction", 'B');
tp2.disp_value();
return 0;
}
Code Snippets
Sample Output
Class Diagram
Pseudocode
class TermpPaper
{
private member variables :
author name, subject paper and
grade
public member functions :
function set_value(argument 1,
argument 2, argument 3)
{
author name is
set to argument 1
paper subject is
set to argument 2
grade is set to
argument 3
}
function disp_value()
{
print author
name
print paper
subject
print
grade
}
}
In main function()
{
Create two objects of TermpPaper class tp1 and
tp2
call member function set_value() for object tp1
call member function disp_value() for object tp1
call member function set_value() for object tp1
call member function disp_value() for object tp1
}