help with project!

Ok I have the header file and implementation file, and need to create one more class(CurvedActivity) to make the program work.

Assignment:

The setScore member function stores a value in score, then calls the determineGrade member function to determine the letter grade. Suppose a teacher wants to “ curve” a numeric score before the letter grade is determined. For example, Dr. Harrison determines that in order to curve the grades in her class she must multiply each student’s score by a certain percentage. This gives an adjusted score, which is used to determine the letter grade.

Write a class CurvedActivity that is derived from the graded activity class. It allows the user to enter the students raw score and curve percentage and print the raw score and curve percentage. In addition is should print the curved grade of the student where curved grade is calculated by multiplying the raw score with a percentage

So if the raw score is 80 and the curve percentage is 1.25, the curved grade is 100 (80*1.25)


Here is the GradedActivity.h header file:
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
// Specification file for the GradedActivity class
#ifndef GRADEDACTIVITY_H
#define GRADEDACTIVITY_H

// GradedActivity class declaration

class GradedActivity
{
protected:
   char letter;            // To hold the letter grade
   double score;           // To hold the numeric score
   void determineGrade();  // Determines the letter grade
public:
   // Default constructor
   GradedActivity()
      { letter = ' '; score = 0.0; }

   // Mutator function
   void setScore(double s) 
      { score = s;
        determineGrade();}
   
   // Accessor functions
   double getScore() const
      { return score; }
   
   char getLetterGrade() const
      { return letter; }
};

#endif 


Here is the GradedActivity.cpp implementation file for the class:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Implementation file for the GradedActivity class
#include "GradedActivity.h"

//******************************************************
// Member function GradedActivity::determineGrade      *
//******************************************************

void GradedActivity::determineGrade()
{
   if (score > 89)
      letter = 'A';
   else if (score > 79)
      letter = 'B';
   else if (score > 69)
      letter = 'C';
   else if (score > 59)
      letter = 'D';
   else
      letter = 'F';
}
Last edited on
What specifically are you stuck on?
pretty much everything lol.. Where does my main function go? How do I compile the program without a main function? I have already created my CurvedActivity.h and CurvedActivity.cpp files, just need to put the correct code in each of them. Shouldn't my main function be called in CurvedActivity.cpp?
Last edited on
Traditionally, the main function should be in a file named Main.cpp, or just in a cpp file of its own. You need to compile it along with all the other cpp files.
Last edited on
I came up with these 3 files, let me know if you think this completes the above assignment:

main.cpp:
1
2
3
4
5
6
7
8
9
10
11
12
#include "CurvedActivity.h"
#include <iostream>
#include <string>

using namespace std;

int main()
{
	CurvedActivity outputObject;

	return 0;
}


curvedactivity.cpp:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Implementation file for the CurvedActivity class
#include "CurvedActivity.h"
#include <iostream>
#include <string>

using namespace std;

CurvedActivity::getCurvedGrade()
{
	cout << "Enter the Raw Score number in decimal format:" << endl;
	cin >> rawScore;
	cout << "Enter the Curve Percentage in decimal format:" << endl;
	cin >> curvePercentage;

	cout << "The Raw Score is: " << rawScore << endl;
	cout << "The Curve Percentage is: " << curvePercentage << endl;

	curvedGrade = rawScore * curvePercentage;

	cout << "The Curved Grade is: " << curvedGrade << endl;

}


curvedactivity.h:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Specification file for the CurvedActivity class
#ifndef CURVEDACTIVITY_H
#define CURVEDACTIVITY_H

// CurvedActivity class declaration

class CurvedActivity
{
protected:
	double rawScore;
	double curvePercentage;
	double curvedGrade;
public:
	getCurvedGrade();
};

#endif 
1. I think you have to do input and output in main, not in any of the functions in your class
2. The assignment mentions another class that your class must derive from
3. You're missing a few member functions that your assignment wants you to have
Topic archived. No new replies allowed.