# Thread: Don't even know where to start.... do while...

1. ## Don't even know where to start.... do while...

ok, this is what i have to do. Using a 90, 80, 70, 60 percent grading scale, if given a list of test scores, print the number of A's, B's, C's, and D's using a do while loop. Terminate the list of scores with a sentinel value.

I am not even sure where to start. so far we only know very basic things... no special header files except iostream, iomanip, cstring. Tis' all. Can anyone help me out? I'd appreciate it every much.

2. One solution is if/else statements.

Kuphryn

3. I'm a complete novice, but one way I can think of is to declare an int for each grade grouping(50-70, 70-100 etc) and start you're do...while loop for the lowest grade category. This first do...while will increment(gradeD++) while the incoming grades fall into this category. After this do...while has completed, execution will move to another do...while that assesses the grades falling into the next highest category. Do the same for the next two categories. Of course there will be grades left on the list, simply place this whole procedure into a while loop that keeps a check on the list of grades and stops looping when all of the grades are removed/read from the list.

4. if you are given the file, read the file into an array, and then loop through the array, and then increment the number of each certain grade. use if statements like kuphryn said...and print the number of each grade. not that difficult...

by the way, what do you mean very basic things, have you learned about arrays?

5. ## Maybe something like this?

Code:
```int CountA = 0;
//...
int CountD = 0;

do
// Get input value

// If > 59 and < 70 CountD++
// If > 69 and < 80 CountC++
// If > 79 and < 90 CountB++
// If > 90 CountA++

}while(Input != SentenialValue):     // Or, you can subtract

cout << CountA << " As" << endl
//etc...```

6. Here's another way with tables :-)
Code:
```#include <iostream>

using namespace std;

{
int values[] = {90, 80, 70, 60};

for (int i = 0; i < max_letters; i++)
{
if (score >= values[i])
{
}
}

return 'I'; // Return incomplete
}

int main()
{
int i = 0;
int scores[] = {97, 62, 84, 76, 92, 78};
int n_grades = sizeof(scores) / sizeof(scores[0]);

do
{
}```

7. ## User input

Okay here's an working example assuming that the user inputs the data from the keyboard... the only thing you would have to do is read from the file in the similar way..
Code:
```#include <iostream>
//#include <cstring>

using namespace std;

int main()
{
int n;
int As = 0;
int Bs = 0;
int Cs = 0;
int Ds = 0;
int Fs = 0;
do
{
cout << "Enter a grade percentage:" << endl;
cin >> n;
if(n>=90)
{
cout << "The letter grade is A" << endl;
As ++;
}

else if(n>=80)
else if(n>=70)