LetterGrade Help

I seem to be having problems I'm not sure what exactly references are used for I'm not sure if I am using them correctly or not. So the objective is to create a program that allows a student to enter his or her score and it determines the score and displays the score entered and the letter grade equivalent to that score. and then create a loop to allow the user to repeat.

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
86
87
88
89
90
91
92
93
94
#include <iostream> //cout and cin
#include <conio.h> //for getch

using namespace std;

	//Function prototypes
	void PrintGrade(int&);
	void GetScore(int&);
	char DetermineGrade(int&);
	void GetResponse(char);

int main()
{
		//Variables
		int studentScore; //a number for student score
		int userResponse = 'Y'; //respone from user

		//Call Functions
		GetScore(studentScore); //get a student score

		DetermineGrade(studentScore); //determine student score

		PrintGrade(studentScore); //display print grade
		
		GetResponse(userResponse); //get response from user

		_getch(); //Hold the screen
}

//***************************************************************************
// Definition of function GetScore.											*
// The parameter number is a reference to an double.						*
// The function asks a user to enter in a score between 0 and 100 inclusive.*
// If the number entered is not within range, an error message will be		*
// displayed, and the user will be asked to try again until a valid score is*
// entered.																	*
//***************************************************************************

void GetScore(int& score)  //number representing month

{
	//Main Title
	cout << "\tLETTER GRADE CALCULATOR\t" << endl
		 <<"----------------------------------" << endl << endl;

	//prompt user to enter a score and read the score
	cout << "Enter a score between 0 and 100 inclusive." << endl;
	cin >> score;

	//Validate Score					
	while (score < 0 || score > 100)
	{
		cout << score << " is not between 0 and 100 inclusive.\n";
		cout << "Try again. Enter a score between 0 and 100 inclusive" << endl;
        cin >> score;  //read score
		cout << endl;
	}

}

//*************************************************************************** 
// Definition of function DetermineScore.
// The parameter score holds an score between 0 and 100 inclusive, and then
// it assigns the score a letter grade.
//***************************************************************************

char DetermineScore(int score)

{
	char grade = 0;
	if(score >=85)
	grade = 'A';
	else if(score >=70)
	grade = 'B';
	else if(score >=60)
	grade = 'C';
	else if(score >=50)
	grade = 'D';
	else 
	grade = 'F';
	return grade;
}

//*************************************************************************** 
// Definition of function PrintGrade.
// The parameter score holds an score between 0 and 100 inclusive, and then
// displays the score and grade
//***************************************************************************

void PrintGrade(int score,char grade)
{
	cout <<"You entered: " << score << endl;
	cout <<"grade: " << grade << endl;
}
I wrote a similar program some weeks ago... Sorry, I'm not really good at explaining, but I hope it helps...

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
#include <iostream> 
using namespace std;


int _tmain(int argc, _TCHAR* argv[])
{
	double numericGrade;       // Declaring numericGrade Variable for grade percentage input, Using double to support decimal values.
	cout << "Please enter the numeric value of your grade,"<< endl << "I will tell you your letter grade: " << endl << endl; 
	// Prints out message to ask the user to input numeric value
	cin >> numericGrade;    // User input numeric Value for grade
	if (numericGrade < 60)         // nested if/else statement, telling the user its grade based on the numeric value inputed
	{
		cout << endl << "Your grade is a F " << endl << endl;
	}
	else
	{
		if (numericGrade < 70)
		{
			cout << endl << "Your Grade is a D " << endl << endl;
		}
		else
		{ 
			if (numericGrade < 80)
			{
				cout << endl << "Your grade is a C " << endl << endl;
			}
			else
			{
				if (numericGrade < 90)
				{ 
					cout << endl << "Your grade is a B " << endl << endl;
				}
				else
				{
					if (numericGrade < 100)
					{
						cout << endl << "Your grade is an A " << endl << endl;
					}
					else
					{
						if (numericGrade >= 100)
						{
							cout << endl << "Congratulations! You have an A + !" << endl << endl;
						}
					}
				}
			}
		}
	}
	system("Pause"); // Pauses the program to wait for user to terminate it
	return 0;
}



@OP
Line 67. You've defined a function named
DetermineScore 
But on line 9 you've forward-declared and on line 21 you've called a function named
DetermineGrade
Resolve this anomaly and see if your program works. Once you get it to work for one grade, you can wrap it in a loop to accept multiple grades.
Last edited on
Topic archived. No new replies allowed.