So for example, what is your expected program output?
This line :
cout << "Total : " << gmmr + splling + correctlength + con << endl;
Should be :
cout << "Total : " << grmmr + splling + correctlength + con << endl;
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
|
// 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;
cout << "Total : " << grmmr + splling + correctlength + con << endl;
EssayClass essayObject(grmmr, splling, correctlength, con);
essayObject.addScore();
essayObject.findGrade();
cout << endl;
cout << "The grade for this essay is : " << essayObject.getGrade() << 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)
{
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 from the looks of it, your problem is solved now?