Finished essay program. How does it look?

Pages: 12
Write your question here.

Header.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#ifndef ESSAY_CLASS_H_INCLUDED
#define ESSAY_CLASS_H_INCLUDED
#include <string>
using namespace std;



class EssayClass
{

//private fields to hold data
private:
    double Grammar;
    double Spelling;
    double CL;
    double Content;
    double score;
    string grade;
//public methods for outside code
public:
    EssayClass (double G, double S, double CL, double con, double score, string grade)
    {
        Grammar = 0.0;
        Spelling = 0.0;
        CL = 0.0;
        Content = 0.0;
        score = 0.0;
        grade=" "
    }

    void addScore(double S, double G, double score, double CL, double con)
    {
        score = Grammar + Spelling + CL + Content;
    }

    void findGrade(double score, string grade)
    {
    if (score>95)
            grade= "A";
        else if (score>79 && score<95)
            grade= "B";
        else if (score >50 && score<79)
            grade= "C";
        else if (score<50)
            grade= "F";

    }
    
    double getGrammar()
    {
        return grammar; 
    }
    
    double getSpelling()
    {
        return spelling;
    }
    
    double getCL()
    {
        return CL;
    }
    
    double getContent()
    {
        return content;
    }
    
    double getScore()
    {
        return score;
    }
    
    string getGrade()
    {
        return grade;
    }
};
#endif // ESSAY_CLASS_H_INCLUDED


Program
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <iostream>
#include "Essay class.h"
#include <string>
using namespace std;
int main ()
{ double grammar;
  double spelling;
  double CL;
  double content;
  string grade;

    cout << "Enter the points for an essay." << endl;
    cout << "Grammar (must be 30 or less points)." << endl;
    cin >> grammar;
    while (grammar>30)
    {
        cout << "Grammar must be 30 or less points." << endl;
        cin >>grammar;
    }
    cout << "Spelling (must be 20 or less points)." << endl;
    cin >> spelling;
    while(spelling>20)
    {
        cout << "Spelling must be 20 or less points." << endl;
        cin>>spelling;
    }
    cout << "Correct length (must be 20 or less points)." << endl;
    cin>>CL;
    while(CL>20)
    {
        cout << "Correct length must be 20 or less points." << endl;
        cin >> CL;
    }
    cout << "Correct content (must be 30 or less points)." << endl;
    cin>>content;
    while(content>30)
    {
        cout << "Content must be 30 or less points." << endl;
        cin >> content;
    }

    cout << "The recorded scores are:" << endl;
    cout << grammar << endl;
    cout << spelling << endl;
    cout << CL << endl;
    cout << content << endl;

    EssayClass essayObject(double G, double S, double CL, double con, double score, string grade);

    essayObject.addScore();
    essayObject.findGrade();

    cout << "The grade for this essay is: " << grade << endl;


return 0;
}


http://prntscr.com/c022ur

I got these two errors when I compiled, but everything else worked!
I got these two errors when I compiled, but everything else worked!
"My car won't start, but everything else about it works!"

Okay. I'm really sorry about that. That is, however, how it comes across. When you get a compilation error, that means that there's something wrong with the written code such that the compiler cannot translate your code into an executable program, not even one that works incorrectly. That really is like your car not being able to start. It may be a simple issue or it may be something more fundamental, but the end result is that you don't have a working car.

That said, there is quite a lot of work that needs to be done here still. Here's the comprehensive list, in no particular order.

For one, line 48 in your main function is a declaration, not a call to the constructor. If you want to avoid making this sort of mistake again and you're set up to use C++11 or later, you can swap the (parentheses) for {curly braces} on that line. If your prof doesn't allow it, then your prof needs a lecture.

Your while loops do not test for negative scores.

grade in your main function never gets set, so on line 53 you're just going to print out nothing in place of an empty grade. It won't result in a crash, but this definitely isn't what you wanted.

Your constructor declared on line 21 of the header takes a bunch of arguments and uses none of them. EDIT: Except the parameter called CL, which shadows the data member also called CL. I'm guessing that wasn't intentional.

addScore takes a bunch of arguments and uses none of them (EDIT: Except for CL, again), yet it's called without any arguments on line 50 in your main function. Either it needs to take arguments, or your constructor needs to set the data members correctly.

findGrade takes a bunch of arguments that end up shadowing your data members, preventing that member function from working correctly. It too is called without arguments. Also, what happens if someone gets a score of 95, 79, or 50?

I don't know if you're expected to do this or not, but as a heads up, using namespace std in a header is especially bad practice. If there's nothing you can do about that, I'm really sorry to hear that. Make that two lectures your prof needs.

-Albatross

EDIT2: Lengthened the preface just to be clear about my intentions with that first line.
Last edited on

For one, line 48 in your main function is a declaration, not a call to the constructor. If you want to avoid making this sort of mistake again and you're set up to use C++11 or later, you can swap the (parentheses) for {curly braces} on that line. If your prof doesn't allow it, then your prof needs a lecture.


How do I fix this one?

I'm also not sure how I'd fix the score one (having a score of 50 and etc).

EDIT

Figured out how.

Your while loops do not test for negative scores.

That's okay for this program for this lesson.

grade in your main function never gets set, so on line 53 you're just going to print out nothing in place of an empty grade. It won't result in a crash, but this definitely isn't what you wanted.

Set grade to " "

Yes, we're expected to use namespace.

This is what I have right now

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//Ashton Dreiling 
//Essay class header
#ifndef ESSAY_CLASS_H_INCLUDED
#define ESSAY_CLASS_H_INCLUDED
#include <string>
using namespace std;



class EssayClass
{

//private fields to hold data
private:
    double Grammar;
    double Spelling;
    double CL;
    double Content;
    double score;
    string grade=" ";
    
//public methods for outside code
public:
    EssayClass ()
    {
        Grammar = 0.0;
        Spelling = 0.0;
        CL = 0.0;
        Content = 0.0;
        score = 0.0;
        grade=" "
    }//end EssayClass constructor 

    //method to add score 
    void addScore()
    {
        score = Grammar + Spelling + CL + Content;
    }// end add score

    //method to show final grade
    void findGrade()
    {
    if (score>95)
            grade= "A";
        else if (score>=79 && score<95)
            grade= "B";
        else if (score >=50 && score<79)
            grade= "C";
        else if (score<=50)
            grade= "F";

    }//end findGrade
    
    double getGrammar()
    {
        return grammar; 
    }//end getGrammar
    
    double getSpelling()
    {
        return spelling;
    }//end getSpelling
    
    double getCL()
    {
        return CL;
    }//end getCL
    
    double getContent()
    {
        return content;
    }//end getContent
    
    double getScore()
    {
        return score;
    }//end getScore
    
    string getGrade()
    {
        return grade;
    }//end getGrade
};//end class
#endif // ESSAY_CLASS_H_INCLUDED


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Ashton Dreiling
//Essay exercise program
#include <iostream>
#include "Essay class.h"
#include <string>
#include <stdlib.h>
using namespace std;

void userInput(double &grammar, double &spelling, double &CL, double &content, string &grade);

int main ()
{
    //some variables
    double grammar;
    double spelling;
    double CL;
    double content;
    string grade;

    userInput(grammar, spelling, CL, content, grade);

    //displaying the scores that were inputed
    cout << "The recorded scores are:" << endl;
    cout << grammar << endl;
    cout << spelling << endl;
    cout << CL << endl;
    cout << content << endl;

    EssayClass eassyObject();
    //calling member functions with essay object
    essayObject.addScore();
    essayObject.findGrade();

    //final grade
    cout << "The grade for this essay is: " << grade << endl;


    system("Pause");
    return 0;
}//end main

void userInput(double &grammar, double &spelling, double &CL, double &content, string &grade)
{

    //input from user to enter points
    cout << "Enter the points for an essay." << endl;
    cout << "Grammar (must be 30 or less points)." << endl;
    cin >> grammar;
    while (grammar>30)
    {
        cout << "Grammar must be 30 or less points." << endl;
        cin >>grammar;
    }//end while loop
    cout << "Spelling (must be 20 or less points)." << endl;
    cin >> spelling;
    while(spelling>20)
    {
        cout << "Spelling must be 20 or less points." << endl;
        cin>>spelling;
    }//end while loop
    cout << "Correct length (must be 20 or less points)." << endl;
    cin>>CL;
    while(CL>20)
    {
        cout << "Correct length must be 20 or less points." << endl;
        cin >> CL;
    }//end while loop
    cout << "Correct content (must be 30 or less points)." << endl;
    cin>>content;
    while(content>30)
    {
        cout << "Content must be 30 or less points." << endl;
        cin >> content;
    }//end while loop
}// end user input 



Last edited on
Oh, nice, you wrote a userInput function. That's actually a good idea. The grade parameter on the end isn't necessary since you don't modify it, but that's minor.

I'm also not sure how I'd fix the score one (having a score of 50 and etc).

You could use the greater-than-or-equal-to operator >= to fix it.

Set grade to " "

There seems to be some confusion here. The grade data member in your class is not the same as the grade object in main. When you set the grade data member to " " in your constructor, grade in main still remains an empty string, and the latter "grade" is the one I'm talking about. The data member grade does get changed in findGrade, but main's grade never gets changed. I would like to point out that you have a getter called getGrade which returns the value of the data member if you need it.

Yes, we're expected to use namespace.

For <REDACTED>'s sake. Very well.

How do I fix this one?

You mostly fixed it, but now we have a problem (besides the minor typo of "eassy").

You removed the parameters from both the constructor and addScore. One of them needs to have some parameters, otherwise addScore is going to be adding a whole bunch of zeroes.

Could we see the problem prompt? That would help clear matters up as to whether the constructor or the member function is supposed to take those arguments (my bet is on the constructor).

-Albatross
Last edited on
Haha, thank. That made me happy. I never get nice compliments because I mainly suck at coding for now.

I had a dumb moment with the greater-than-or-equal to, but I managed to catch it before you commented luckily so I don't look too foolish.

I hope I understand what you mean with the grade thing now.

I set both grades to " " if that's what you mean.

We have to call using

 
essayObject.findGrade();


Unfortunately for not.

Could you show me how I'd add arguments to the addScore method?

This is the prompt.
http://prntscr.com/c02gmq

: )

Thanks for being a life savior again.

I have one hour and one more program to edit haha.
I think I spy a link in that prompt. Could we also see the linked Essay Design bit, please?

-Albatross
Haha, yes, but I don't think it will be much help.

http://prntscr.com/c02j3i

If it helps, I'm pretty sure it's the constructor.
...oh, no. You said you have only forty minutes now, right?

Essay is supposed to inherit from another class called GradedActivity, which provides the score data member among other things. Neither the constructor nor addScore are supposed to take arguments, but the data members are supposed to be set through several setters that don't exist in your Essay class. Additionally, there's supposed to be a member function that displays the points (takes care of most of the printing you were doing in main).

-Albatross
Thirty now. I have If I'm lucky I only have to spend ten more minutes on this haha.

Also, we don't have to do it exactly like it was shown in the UML. : )

That's just a suggestive approach. As long as we get it like the output that was shown, we're all good from what I know. So, we continue working on this how we've been.
Alright. I hope you're right.

In that case, I'd have the constructor take them. As an example of a constructor that takes arguments (this is an example, and can't be copy/pasted):

1
2
3
4
Essay(string author, double grade) { //*
    essayAuthor = author;
    essayGrade = grade;
}


...which could be called and the resulting object used as such:

1
2
3
4
5
6
string auth = "Charles Darwin";
double grade = 85.7;
Essay ess(auth, grade); //*
ess.addScore();
ess.findGrade();
string result = ess.getGrade();


-Albatross

*I know, there's a better syntax for this, but now isn't the time for language purism.
1
2
3
4
5
 //method to add score 
    void addScore(double score, double grammar, double spelling, double CL, double content)
    {
        score = Grammar + Spelling + CL + Content;
    }// end add score 


Like this?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//Ashton Dreiling
//Essay class header
#ifndef ESSAY_CLASS_H_INCLUDED
#define ESSAY_CLASS_H_INCLUDED
#include <string>
using namespace std;



class EssayClass
{

//private fields to hold data
private:
    double Grammar;
    double Spelling;
    double CL;
    double Content;
    double score;
    string grade=" ";

//public methods for outside code
public:
    EssayClass ()
    {
        Grammar = 0.0;
        Spelling = 0.0;
        CL = 0.0;
        Content = 0.0;
        score = 0.0;
        grade=" "
    }//end EssayClass constructor

    //method to add score
    void addScore(double score)
    {
        score = Grammar + Spelling + CL + Content;
    }// end add score

    //method to show final grade
    void findGrade()
    {
    if (score>=95)
            grade= "A";
        else if (score>=79)
            grade= "B";
        else if (score >=50)
            grade= "C";
        else if (score<=50)
            grade= "F";

    }//end findGrade

    double getGrammar()
    {
        return grammar;
    }//end getGrammar

    double getSpelling()
    {
        return spelling;
    }//end getSpelling

    double getCL()
    {
        return CL;
    }//end getCL

    double getContent()
    {
        return content;
    }//end getContent

    double getScore()
    {
        return score;
    }//end getScore

    string getGrade()
    {
        return grade;
    }//end getGrade
};//end class
#endif // ESSAY_CLASS_H_INCLUDED 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Ashton Dreiling
//Essay exercise program
#include <iostream>
#include "Essay class.h"
#include <string>
#include <stdlib.h>

const int NUM_FOR_CAL1=0;
using namespace std;

void userInput(double &grammar, double &spelling, double &CL, double &content, string &grade);

int main ()
{
    //some variables
    double grammar;
    double spelling;
    double CL;
    double content;
    string grade=" ";

    userInput(grammar, spelling, CL, content, grade);

    //displaying the scores that were inputed
    cout << "The recorded scores are:" << endl;
    cout << grammar << endl;
    cout << spelling << endl;
    cout << CL << endl;
    cout << content << endl;

    EssayClass eassyObject();
    //calling member functions with essay object
    essayObject.addScore();
    essayObject.findGrade();

    //final grade
    cout << "The grade for this essay is: " << grade << endl;


    system("Pause");
    return 0;
}//end main

void userInput(double &grammar, double &spelling, double &CL, double &content, string &grade)
{

    //input from user to enter points
    cout << "Enter the points for an essay." << endl;
    cout << "Grammar (must be 30 or less points)." << endl;
    cin >> grammar;
    while (grammar>30 || grammar<NUM_FOR_CAL1)
    {
        cout << "Grammar must be 30 or less points." << endl;
        cin >>grammar;
    }//end while loop
    cout << "Spelling (must be 20 or less points)." << endl;
    cin >> spelling;
    while(spelling>20 || spelling<NUM_FOR_CAL1)
    {
        cout << "Spelling must be 20 or less points." << endl;
        cin>>spelling;
    }//end while loop
    cout << "Correct length (must be 20 or less points)." << endl;
    cin>>CL;
    while(CL>20 || CL<NUM_FOR_CAL1)
    {
        cout << "Correct length must be 20 or less points." << endl;
        cin >> CL;
    }//end while loop
    cout << "Correct content (must be 30 or less points)." << endl;
    cin>>content;
    while(content>30 || content<NUM_FOR_CAL1)
    {
        cout << "Content must be 30 or less points." << endl;
        cin >> content;
    }//end while loop
}// end user input 


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//Ashton Dreiling
//Essay class header
#ifndef ESSAY_CLASS_H_INCLUDED
#define ESSAY_CLASS_H_INCLUDED
#include <string>
using namespace std;



class EssayClass
{

//private fields to hold data
private:
    double Grammar;
    double Spelling;
    double CL;
    double Content;
    double score;
    string grade=" ";

//public methods for outside code
public:
    EssayClass ()
    {
        Grammar = 0.0;
        Spelling = 0.0;
        CL = 0.0;
        Content = 0.0;
        score = 0.0;
        grade=" ";
    }//end EssayClass constructor

    //method to add score
    void addScore(double scr)
    {
        score = Grammar + Spelling + CL + Content;
    }// end add score

    //method to show final grade
    void findGrade()
    {
    if (score>=95)
            grade= "A";
        else if (score>=79)
            grade= "B";
        else if (score >=50)
            grade= "C";
        else if (score<=50)
            grade= "F";

    }//end findGrade

    double getGrammar()
    {
        return Grammar;
    }//end getGrammar

    double getSpelling()
    {
        return Spelling;
    }//end getSpelling

    double getCL()
    {
        return CL;
    }//end getCL

    double getContent()
    {
        return Content;
    }//end getContent

    double getScore()
    {
        return score;
    }//end getScore

    string getGrade()
    {
        return grade;
    }//end getGrade
};//end class
#endif // ESSAY_CLASS_H_INCLUDED 
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// Ashton Dreiling
//Essay exercise program
#include <iostream>
#include "Essay class.h"
#include <string>
#include <stdlib.h>

const int NUM_FOR_CAL1=0;
using namespace std;

void userInput(double &grammar, double &spelling, double &CL, double &content, string &grade);

int main ()
{
    //some variables
    double grammar;
    double spelling;
    double CL;
    double content;
    double scr;
    string grade=" ";

    userInput(grammar, spelling, CL, content, grade);

    //displaying the scores that were inputed
    cout << "The recorded scores are:" << endl;
    cout << "Grammar: " << grammar << endl;
    cout << "Spelling: " << spelling << endl;
    cout << "Correct Length: " << CL << endl;
    cout << "Content: " << content << endl;

    EssayClass essayObject;
    //calling member functions with essay object
    essayObject.addScore(scr);
    essayObject.findGrade();

    //final grade
    cout << "The grade for this essay is: " << grade << endl;


    system("Pause");
    return 0;
}//end main

void userInput(double &grammar, double &spelling, double &CL, double &content, string &grade)
{

    //input from user to enter points
    cout << "Enter the points for an essay." << endl;
    cout << "Grammar (must be 30 or less points)." << endl;
    cin >> grammar;
    while (grammar>30 || grammar<NUM_FOR_CAL1)
    {
        cout << "Grammar must be 30 or less points." << endl;
        cin >>grammar;
    }//end while loop
    cout << "Spelling (must be 20 or less points)." << endl;
    cin >> spelling;
    while(spelling>20 || spelling<NUM_FOR_CAL1)
    {
        cout << "Spelling must be 20 or less points." << endl;
        cin>>spelling;
    }//end while loop
    cout << "Correct length (must be 20 or less points)." << endl;
    cin>>CL;
    while(CL>20 || CL<NUM_FOR_CAL1)
    {
        cout << "Correct length must be 20 or less points." << endl;
        cin >> CL;
    }//end while loop
    cout << "Correct content (must be 30 or less points)." << endl;
    cin>>content;
    while(content>30 || content<NUM_FOR_CAL1)
    {
        cout << "Content must be 30 or less points." << endl;
        cin >> content;
    }//end while loop
}// end user input 


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//Ashton Dreiling
//Essay class header
#ifndef ESSAY_CLASS_H_INCLUDED
#define ESSAY_CLASS_H_INCLUDED
#include <string>
using namespace std;



class EssayClass
{

//private fields to hold data
private:
    double Grammar;
    double Spelling;
    double CL;
    double Content;
    double score;
    string grade=" ";
//public methods for outside code
public:
    EssayClass()
    {
        Grammar = 0.0;
        Spelling = 0.0;
        CL = 0.0;
        Content = 0.0;
        score = 0.0;
        grade=" ";
    }//end EssayClass constructor

    //method to add score
    void addScore(double scr)
    {
        score = Grammar + Spelling + CL + Content;
    }// end add score

    //method to show final grade
    void findGrade()
    {
    if (score>=95)
            grade= "A";
        else if (score>=79)
            grade= "B";
        else if (score >=50)
            grade= "C";
        else if (score<=50)
            grade= "F";

    }//end findGrade

    double getGrammar()
    {
        return Grammar;
    }//end getGrammar

    double getSpelling()
    {
        return Spelling;
    }//end getSpelling

    double getCL()
    {
        return CL;
    }//end getCL

    double getContent()
    {
        return Content;
    }//end getContent

    double getScore()
    {
        return score;
    }//end getScore

    string getGrade()
    {
        return grade;
    }//end getGrade
};//end class
#endif // ESSAY_CLASS_H_INCLUDED 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// Ashton Dreiling
//Essay exercise program
#include <iostream>
#include "Essay class.h"
#include <string>
#include <stdlib.h>

const int NUM_FOR_CAL1=0;
using namespace std;

void userInput(double &grammar, double &spelling, double &CL, double &content);

int main ()
{
    //some variables
    double grmmr;
    double splling;
    double correctlength;
    double con;
    double scr;
    string grde;



    userInput(grmmr, splling, correctlength, con);

    //displaying the scores that were inputed
    cout << "The recorded scores are:" << endl;
    cout << "Grammar: " << grmmr << endl;
    cout << "Spelling: " << splling << endl;
    cout << "Correct Length: " << correctlength << endl;
    cout << "Content: " << con << endl;

    EssayClass essayObject(grmmr, splling, correctlength, scr, con, grde);
    //calling member functions with essay object
    userInput(grmmr, splling, correctlength, con);

    essayObject.addScore();
    essayObject.findGrade();
    essayObject.getGrade();
    string grde=essayObject.getGrade();


    //final grade
    cout << "The grade for this essay is: " << grde << endl;


    system("Pause");
    return 0;
}//end main

void userInput(double &grmmr, double &splling, double &correctlenght, double &con)
{

    //input from user to enter points
    cout << "Enter the points for an essay." << endl;
    cout << "Grammar (must be 30 or less points)." << endl;
    cin >> grmmr;
    while (grmmr>30 || grmmr<NUM_FOR_CAL1)
    {
        cout << "Grammar must be 30 or less points." << endl;
        cin >>grmmr;
    }//end while loop
    cout << "Spelling (must be 20 or less points)." << endl;
    cin >> splling;
    while(splling>20 || splling<NUM_FOR_CAL1)
    {
        cout << "Spelling must be 20 or less points." << endl;
        cin>>splling;
    }//end while loop
    cout << "Correct length (must be 20 or less points)." << endl;
    cin>>correctlenght;
    while(correctlenght>20 || correctlenght<NUM_FOR_CAL1)
    {
        cout << "Correct length must be 20 or less points." << endl;
        cin >> correctlenght;
    }//end while loop
    cout << "Correct content (must be 30 or less points)." << endl;
    cin>>con;
    while(con>30 || con<NUM_FOR_CAL1)
    {
        cout << "Content must be 30 or less points." << endl;
        cin >> con;
    }//end while loop
}// end user input 







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//Ashton Dreiling
//Essay class header
#ifndef ESSAY_CLASS_H_INCLUDED
#define ESSAY_CLASS_H_INCLUDED
#include <string>
using namespace std;



class EssayClass
{

//private fields to hold data
private:
    double Grammar;
    double Spelling;
    double CL;
    double Content;
    double score;
    string grade;
//public methods for outside code
public:
    EssayClass(double G, double S, double corlen, double content, double Score, string Grade)
    {
        Grammar = G;
        Spelling = S;
        CL = corlen;
        Content = content;
        score=Score;
        grade=Grade;
    }//end EssayClass constructor

    //method to add score
    void addScore()
    {
        score = Grammar + Spelling + CL + Content;
    }// end add score

    //method to show final grade
    void findGrade()
    {
    if (score>=95)
            grade= "A";
        else if (score>=79)
            grade= "B";
        else if (score >=50)
            grade= "C";
        else if (score<=50)
            grade= "F";

    }//end findGrade

    double getGrammar()
    {
        return Grammar;
    }//end getGrammar

    double getSpelling()
    {
        return Spelling;
    }//end getSpelling

    double getCL()
    {
        return CL;
    }//end getCL

    double getContent()
    {
        return Content;
    }//end getContent

    double getScore()
    {
        return score;
    }//end getScore

    string getGrade()
    {
        return grade;
    }//end getGrade
};//end class
#endif // ESSAY_CLASS_H_INCLUDED 
Last edited on
So what is your problem?
string grde = essayObject.getGrade();

Should be :
grde = essayObject.getGrade();
Last edited on
Does that help? :)
Pages: 12