Issue declaring paper1

I need to design a class named TermPaper that holds an author's name, the subject of the paper, and an assigned letter grade. I am stuck on how to define and set paper1??

#include <iostream>
#include <cstdlib>
#include <string>
#include "termpaper.h"

using namespace std;

int main()

{
string firstName;
string lastName;
string subject;
char grade;


cout << "Please enter first name. ";
cin >> firstName;

cout << "Please enter last name. ";
cin >> lastName;

cout << "Please enter subject. ";
cin >> subject;

cout << "Please enter letter grade. ";
cin >> grade;

//Set the first name for paper1
//Set the last name for paper1
//Set the subject for paper1
//Set the letter grade for paper1


cout << "First Name: ", paper1.getFirstName();
cout << "Last Name: ", paper1.getLastName();
cout << "Subject: ", paper1.getSubject();
cout << "Grade: ", paper1.getGrade();

system("Pause");
return 0;
}


// Start
// Declarations
// TermPaper paper1
// string firstName
// string lastName
// string subject
// character grade
// output "Please enter first name. "
// input firstName
// output "Please enter last name. "
// input lastName
// output "Please enter subject. "
// input subject
// output "Please enter letter grade. "
// input grade
// Set the first name for paper1
// Set the last name for paper1
// Set the subject for paper1
// Set the letter grade for paper1
// output "First Name: ", paper1.getFirstName()
// output "Last Name: ", paper1.getLastName()
// output "Subject: ", paper1.getSubject()
// output "Grade: ", paper1.getGrade()
// Stop





closed account (3qX21hU5)
Before going about setting paper1 you need to define your TermPaper class.

1
2
3
4
class TermPaper
{
    // Your stuff here
}


I would suggest you start by defining that class then come back here and post what you have done. So far it looks like you haven't done anything. If you don't know how classes work I would highly suggest you look at our tutorial here on them or any resource you have about classes.


EDIT: Missed the TermPaper.h header so you can disregard everything I said. I figured you had to create the class by yourself.
Last edited on
The code to use is in the example, it's just missing the semicolon.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Start
// Declarations
// TermPaper paper1
// string firstName
// string lastName
// string subject
// character grade
// output "Please enter first name. "
// input firstName
// output "Please enter last name. "
// input lastName
// output "Please enter subject. "
// input subject
// output "Please enter letter grade. "
// input grade
// Set the first name for paper1
// Set the last name for paper1
// Set the subject for paper1
// Set the letter grade for paper1
// output "First Name: ", paper1.getFirstName()
// output "Last Name: ", paper1.getLastName()
// output "Subject: ", paper1.getSubject()
// output "Grade: ", paper1.getGrade()
// Stop  
I don't know why I am struggling with this so much I can not figure out how to set the first name, last name, subject, and grade for paper1?? Im sorry I just missed // TermPaper paper1 in the example

#include <iostream>
#include <cstdlib>
#include <string>
#include "termpaper.h"


using namespace std;

int main()


{
TermPaper paper1;
string firstName;
string lastName;
string subject;
char grade;



cout << "Please enter first name. ";
cin >> firstName;

cout << "Please enter last name. ";
cin >> lastName;

cout << "Please enter subject. ";
cin >> subject;

cout << "Please enter letter grade. ";
cin >> grade;

//Set the first name for paper1
//Set the last name for paper1
//Set the subject for paper1
//Set the letter grade for paper1


cout << "First Name: ", paper1.getFirstName();
cout << "Last Name: ", paper1.getLastName();
cout << "Subject: ", paper1.getSubject();
cout << "Grade: ", paper1.getGrade();

system("Pause");
return 0;
}


closed account (3qX21hU5)
Again I would highly highly suggest you go back and start over from the beginning with any resource you have that teaches you about classes. These are some of the most basic parts of classes and you need to know them to continue.

COPY AND PASTING CODE WILL DO NOTHING FOR YOU AND WILL JUST HURT YOU IN THE END. I say this because all you have done is copied and pasted this code from another topic on this forum. You haven't changed it one bit http://www.cplusplus.com/forum/beginner/101137/

I would suggest you start over from scratch and work through the parts you know step by step. Once you have done that come back and we can help.

But for now I for one will not help you because you have put no effort into your assignment. Hell you didn't even put a effort into understanding the code you copied and pasted...
Last edited on
Sorry but I did not copy and paste. I think we are in the same class because the assignment is due today and the other person asked for help this weekend also. I am in the process of looking for tutorials and other options. I am just having a hard time grasping all of this. Thank you for the help I will try to figure it out.
zigfl03 wrote:
I can not figure out how to set the first name, last name, subject, and grade for paper1??
Based on the code in Giggidy's post,
1
2
3
4
paper1.setFName(/*put something here*/);
paper1.setLName(/*put something here*/);
paper1.setSubject(/*put something here*/);
paper1.setLetterGrade(/*put something here*/);
You will need to use those variables you made (firstName, lastName, subject, grade).
Last edited on
Thank you for the help. Still have some errors but I will figure it out.
Topic archived. No new replies allowed.