#include <iostream>
#include "EssayClass.h"
usingnamespace std;
int main (){
double score1, score2, score3, score4;
EssayClass Student;
cout << "Please enter up to 30 points for Grammar: ";
cin >> score1 ;
cout << "Please enter up to 20 points for Spelling: ";
cin >> score2 ;
cout << "Please enter up to 20 points for Correct Length: ";
cin >> score3 ;
cout << "Please enter up to 30 points for Content: ";
cin >> score4;
Student.setScore(score1, score2, score3, score4) ;
Student.addScore();
Student.getScore();
Student.FindletterGrade();
Student.getletterGrade();
}
My code is running fine, but when I call the return function in my header file nothing outputs.
The returned values of the member functions being called are not being written to any output stream like the data in the preceding statements. If you wish to write them to the standard output stream, then simply pass the returned values as arguments to the std::cout::operator << (...) member function. Otherwise, use one of the other methods of outputting data.
You aren't outputting them (I'm assuming you're talking about the last three lines of your main function).
You are simply calling the function. In your case, that is not enough because the functions don't print inherently; they only return the values. So, you have to print the functions... so to speak.
#include <iostream>
#include "EssayClass.h"
usingnamespace std;
int main (){
double score1, score2, score3, score4;
EssayClass Student;
cout << "Please enter up to 30 points for Grammar: ";
cin >> score1 ;
cout << "Please enter up to 20 points for Spelling: ";
cin >> score2 ;
cout << "Please enter up to 20 points for Correct Length: ";
cin >> score3 ;
cout << "Please enter up to 30 points for Content: ";
cin >> score4;
Student.setScore(score1, score2, score3, score4) ;
Student.addScore();
Student.FindletterGrade();
cout << "Student received a " << Student.getScore();
cout << " out of 100 on the essay. Student receives a(n) " <<
Student.getletterGrade();
cout << " on the assignment.";
return 0;
}
One more thing to mention. Headers are mainly for prototypes and only definitions of templated functions. Then an implementation file is used for the definitions.
//test.hpp
class Test
{
public:
void test( void );
};
//test.cpp
#include "test.hpp"
void Test::test( void )
{
//nothing since I am a test
}
//main.cpp
#include "test.hpp"
int main()
{
return 0;
}