returning a letter from score totals

I'm trying to creat a function that will take the score input
and give the output in a letter grade form of the total that got the score within that range.

This is what I have but it doesn't work.
Can I get help?

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
/display scores total by grade
    scoreByGrade


    cout << "Number of students earning a score of " << enteredScoreA_count << ": " 
    << enteredScoreA << endl; 
    cout << "Number of students earning a score of " << enteredScoreB_count << ": " 
     << enteredScoreB << endl; 
    cout << "Number of students earning a score of " << enteredScoreC_count << ": " 
     << enteredScoreC << endl; 
    cout << "Number of students earning a score of " << enteredScoreD_count << ": " 
     << enteredScoreD << endl; 
    cout << "Number of students earning a score of " << enteredScoreF_count << ": " 
     << enteredScoreF << endl; 

//*********function definitions**********
// Count of letter grades entered

void scoreByGrade (int enteredScoreA_count=0, enteredScoreB_count=0, enteredScoreC_count=0,
enteredScoreADcount=0,enteredScoreF_count=0)


while(grade != SENTINEL) // Add to grade counts until SENTINEL is entered.
{
	switch(scores)
	{
	case 'A':
	enteredScoreA++; // Add 1 to count of A grades
	break;

	case 'B':
	enteredScoreB++; // Add 1 to count of B grades
	break;

	case 'C':
	enteredScoreC_count++; // Add 1 to count of C grades
	break;

	case 'D':
	enteredScoreD_count++; // Add 1 to count of D grades
	break;

	case 'F':
	enteredScoreD_count++; // Add 1 to count of F grades
	break;



	}


 }

 // end switch 



it sounds to me like you want to test the score against a particular range of scores and issue a letter grade accordingly:
1
2
3
if(score > 90) return 'A';
if(score > 75) return 'B';
// etc... 

Something like that?
Last edited on
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
// Just something for no reason.
#include <iostream>
#include <cctype>
// It seems to me that you want to make a program that tallies
// the amount of A's B's and etc you enter and then report it.
using namespace std;

struct gradetally { // Keeps the tally of the inputted grades.
    int a,b,c,d,f;
}basic; // Just go ahead and make this object.

int main() {
    string myEntry;

    // I made the do while {} block like this so it'll be fast, be able to accept both
    // upper and lower case, and also have no problem taking other mistaken input without error.
    // It just discards it, also it confirms a successful grade input.

    do {
        cout << "Input grade : ";
        cin >> myEntry;
        if(myEntry=="A"|| myEntry == "a") {
            basic.a++; cout << "Confirmed" << endl;
        } else if(myEntry=="B"|| myEntry=="b") {
            basic.b++; cout << "Confirmed" << endl;
        } else if(myEntry=="C"|| myEntry=="c") {
            basic.c++; cout <<"Confirmed" <<endl;
        } else if(myEntry=="D"|| myEntry=="d") {
            basic.d++; cout <<"Confirmed" << endl;
        } else if(myEntry=="F"|| myEntry=="f") {
            basic.f++; cout << "Confirmed" << endl;
        }

    } while( myEntry != "SENTINEL" ); // Input SENTINEL and it dies and reports the results.

    // Show results of your inputting.
    cout << "Amount of A's : " << basic.a << endl;
    cout << "Amount of B's : " << basic.b << endl;
    cout << "Amount of C's : " << basic.c << endl;
    cout << "Amount of D's : " << basic.d << endl;
    cout << "Amount of F's : " << basic.f << endl;


}


Something like that?
Topic archived. No new replies allowed.