1
I am facing problems with this code, when running it the default runs also and in no time I entered with some data other than in the cases.
// faz loop até usuário digitar a sequência de teclas de fim do arquivo
while ((grade = cin.get()) != EOF)
{
// determina a nota que foi inserida
switch (grade)
{
case 'A':
case 'a':
aCount++;
break;
case 'B':
case 'b':
bCount++;
break;
case 'C':
case 'c':
cCount++;
break;
case 'D':
case 'd':
dCount++;
break;
case 'F':
case 'f':
fCount++;
break;
default:
cout << "Incorrect letter grade entered." << " Enter a new grade." << endl;
} // fim do switch
} // fim do while
Could someone tell me what’s going on, has to do with the buffer of the keyboard that picks up the \n
when do I enter the data? How to resolve this?
Managed to solve the problem? has something to improve on some of the answers?
– stderr