Trying to have a user input their grades as letter values and then assigning the letters numbers to be saved in an array. For some reason I can't get case 1 to work correctly. All it does is ask for the lab and then the grade, but once you input a letter (i.e. A, B, C, D, F) it gets in an infinite loop.
#include <iostream> //References iostream library to be used
using namespace std; //Makes the library available
void main()
{
int Counter=1; //Counter for letter nested statement
int Assignment[7]= {0, 0, 0, 0, 0, 0, 0}; //Array
int Selection, Lab, LabGrade, Count; //Declare variables
char A, B, C, D, F; //Assignment letter variables
float GPA; //float variable to allow for decimals
float Divisor = 7.0;
//Selection menu for grades
cout << "Please select for pay type from the following choices:\n";
cout << " 1 - Input Letter Grade Data\n";
cout << " 2 - Lab Average\n";
cout << " 3 - Print Lab Grades to Screen\n";
cout << " 0 - Exit\n";
cin >> Selection;
while (Selection != 0)
{
switch (Selection)
{
case (1):
while
{
cout << "Enter lab number (1-7): \n";
cin >> Lab;
cout << "Enter current grade for lab: \n";
cin >> LabGrade;
if (LabGrade = 'A' && 'a')
{
A = 4;
}
else
{
if (LabGrade = 'B' && 'b')
{
B = 3;
}
else
{
if (LabGrade = 'C' && 'c')
{
C = 2;
}
else
{
if (LabGrade = 'D' && 'd')
{
D = 1;
}
else
{
if (LabGrade = 'F' && 'f')
{
F = 0;
}
}
}
}
}
}
Assignment[Lab-1] = LabGrade;
cout << "Current lab " << Lab << ", is now " << LabGrade << ".\n\n";
break;
case (2):
GPA = 0.0;
for (Count=0; Count <=6; Count++)
{
GPA = GPA + Assignment[Count];
}
cout << "Current lab average is " << GPA / Divisor << ".\n\n";
break;
case (3):
Count = 0;
while (Count <= 6)
{
cout << "Lab " << Count+1 << " grade is " << Assignment[Count] << ".\n";
Count++;
}
break;
default:
cout << "Enter correct menu selection.\n";
}
cout << " 1 - Input Letter Grade Data\n";
cout << " 2 - Lab Average\n";
cout << " 3 - Print Lab Grades to Screen\n";
cout << " 0 - Exit\n";
cin >> Selection;
}
}