Help with gpa calculator




int test;
int test1;
int totalPoints;
int counter;



int gradePoints;
char letterGrade;
float gpa;





// OUTPUT - Class Heading
cout << left;
cout << "***************************************************";
cout << "\n* PROGRAMMED BY : " << PROGRAMMER;
cout << "\n* " << setw(14) << "CLASS" << ": " << CLASS;
cout << "\n* " << setw(14) << "SECTION" << ": " << SECTION;
cout << "\n* LAB #" << setw(9) << LAB_NUM << ": " << LAB_NAME;
cout << "\n***************************************************\n\n";
cout << right;

// INPUT - user will input the class code to determine if the class
// code is valid or invalid.

for (test = 1 ;test <= TEST_CASE; test = test + 1)
{

gradePoints = 0;
letterGrade = 1;

counter = 0;

cout << "TEST CASE #"
<< test
<< ":"
<< endl;

cout << left
<< setw(20)
<< "Enter Letter Grade "
<< test
<< "#"
<< right;

cin.get(letterGrade);
cin.ignore(10000, '\n');


letterGrade = toupper(letterGrade);


while (letterGrade != 'x')
{

letterGrade = toupper(letterGrade);



cout << left
<< setw(20)
<< "Enter Letter Grade "
<< test
<< "#"
<< right;

cin.get(letterGrade);
cin.ignore(10000, '\n');



switch (letterGrade)

{
toupper(letterGrade);


case 'A' : gradePoints = gradePoints + 4;
break;

case 'B' : gradePoints = gradePoints + 3 ;
break;

case 'C' : gradePoints = gradePoints + 2;
break;

case 'D' : gradePoints = gradePoints + 1;
break;

case 'F' : gradePoints = gradePoints + 0;
break;


}

counter = counter + 1;




}



if(letterGrade > 0)

cout << "Total Grade Points: ";


cout << gradePoints;
cout << endl;

cout << "GPA: ";


cout << letterGrade;
cout << endl;
cout << endl;
cout << endl;



}
















return 0;


}




OUTPUT

TEST CASE #1:
Enter Letter Grade 1#A
Enter Letter Grade 1#A
Enter Letter Grade 1#x
Enter Letter Grade 1#X
Total Grade Points: 4
GPA: X


My code is not adding right and the letter grande number needs to be increasing. not #1 #1 #1

i cant seem to find whats wrong.

maybe i need a second counter in while loop.

any advice.?



















Topic archived. No new replies allowed.