## Dontais

I'm probably just confusing myself, but what the basic idea is I put in a grade and it outputs if the grade is an f, c, d ... etc. It allows me to enter a number and after I enter it it will continue to show F! repetitively. After this happens I haft to close the program or it continues forever it seems.

``````int main ()
{
cout << setprecision(1) << fixed;

cout << "Enter the Students Grade Between 1 and 100 (-1 to stop):\n";

{

{
cout << "F!"<< endl;
}
{
cout << "D!" << endl;
}
{
cout << "C!" << endl;
}
}

return 0;
}``````

## Agni 370

While loop is obviously not the right choice here .. whatever grade you enter will satisfy the condition always and the loop becomes infinite... just a simple 'if' should do i think if its to happen only once. or else you can use a 'yes'-'no' sort of menu.

## ArkM 1,090

``````int grade;
while (std::cout << "Enter the Students Grade [1..100]\n"
"or not-a-number to quit: " << std::flush,
{
else { // ?????????
reply = "Mea culpa: else missed...";
}
}``````

## stilllearning 148

You need to ask the question to input the grade inside your while loop, else it will keep looping on your first input infinitely !!

``````int main ()
{
cout << setprecision(1) << fixed;
cout << "Enter the Students Grade Between 1 and 100 (-1 to stop):\n";

{
cout << "F!"<< endl;
}
{
cout << "D!" << endl;
}
{
cout << "C!" << endl;
}
cout << "Enter the Students Grade Between 1 and 100 (-1 to stop):\n";
}

return 0;
}``````

## Denniz 103

With minimum change to what you already have:

``````while ((grade > 0) && (grade <= 100))
{
cout << "Enter the Students Grade Between 1 and 100 (-1 to stop):\n";
{
cout << "F!"<< endl;
}
{
cout << "D!" << endl;
}
{
cout << "C!" << endl;
}
}``````

## grumpier 149

You seem to have solved the looping problem, except that in most tests a grade of zero is possible and your (grade > 0) condition excludes that.

An aside: I knew a teacher who came up with a test that, she said, nobody could earn a zero grade .... because there was one mark for candidates spelling their name correctly. One of her students mispelt his name.

## Denniz 103

You seem to have solved the looping problem, except that in most tests a grade of zero is possible and your (grade > 0) condition excludes that.

If you are refering to the solution I provided, that's because he prompt the user to enter a score between 1 to 100 in his original question.

## Dontais

Thanks for the help I see what I did now, I managed to get it working and I added (grade < -1) just in case of a 0 grade even though it says 1-100.