When i build this code i get an error on the #include "GradeBook.h"
//Definition ogf class GradeBook thyat determines class average
//Member functions are defined in Gradebook.cpp
#include <string> //program uses c++ standard string class
using namesapce std;
//GradeBook class definition
class GradeBook
{
public:
GradeBook(string); //Constructor initializes course name
void setCourseName (string); //function to set the course name
string getCourseNmae(); //function to retrieve the course name
void displayMessage(); //display a welcome message
void determineClassAverage(); //averages grades entered by the user
private:
string courseName; //course name for this grade book
};
//member functions for class GradeBook that solves the
//class average program with counter-controlled repetition.
#include <iostream>
#include "GradeBook.h" //include dcefinition of class GradeBook
using namespace std;
//constructor initialiazes courseName with string supplied as argument
GradeBook::GradeBook (string name)
{
setCourseName (name); //validate and strore coursename
} //end GradeBook constructor
//function to set the course name;
//ensures that the course name has at most 25 characters
void GradeBook::setCourse (string name)
{
if (name.length() <= 25) //if name has 25 of fewer characters
else //if name is is longer than 25 characters
{ //set course name to fisrt 25 characters of of paramter name
courseName = name.substr (0, 25); //select first 25 characters
cout << "Name \"" << name << "\"exceeds maximum length (25).\n"
<<"Limiting courseName to first 25 characters.\n" << endl;
} //end if ..... else
} //end function setCourseName
//function to retrieve the course name
string GradeBook::getCourseName()
{
return courseName;
} //end function getCourseName
//display a welcome message to the GradeBook user
void GradeBook::displayMessage ()
{
cout <<"Welcome to the Grade Book for\n" << getCourseName << "!\n
<< endl;
} // end function displayMessage
//determine class average based on 10 grades entered by user
void GradeBook::determineClassAverage()
{
int total; //sum of grade entered by the user
int gradeCounter; //number of grade to be entered next
int grade; //grade value entered by the user
int average; //average of grades
//initialization phase
total = 0; //initializal total
gradeCounter = 1; //initialize loop counter
//processing phase
while (gradeCounter <= 10) //loop 10 times
{
cout <<"Enter grade:"; //prompt for input
cin >> grade; //input next grade
total = total + grade; //add grade to total
gradeCounter = gradeCounter + 1; //increment counter by 1
} //end while
//termination phase
average = total/10; //inter divison yields integer result
//display total and average grades
cout <<"\nTotal of all 10 grades is " << total << endl;
cout <<"Class average is " << average << endl;
} //end fucntion determineClassAverage
Should we say: "an answer" to match the level of detail?
Compiler errors are usually very verbose an do contain useful information that one should learn to make use of.