loop help

Hi, I've trying to do this program:

Write a C++ program that determines a letter grade for a student based on two test scores. For a numeric average x, the following grade scale is used:

Grade Range
A 90.0 ≤ x ≤ 100.0
B 80.0 ≤ x < 90.0
C 70.0 ≤ x < 80.0
Fail x < 70.0

For each student, the program will need to get two test scores from the user; both scores should be positive floating point numbers and can include 0.0. If the user enters a negative number, display an appropriate error message and reprompt the user. When the user enters two valid positive numbers, the pro-gram should calculate the average and display to the console the corresponding grade given in the first column of the table above.


The program should continue to process student scores until one of the fol-lowing occurs:

• Three passing grades have been computed. The program should then print the message “PASSING QUOTA MET” to the console and terminate.

• Two failing grades have been computed. The program should then print the message “FAILING QUOTA MET” to the console and terminate.


Two sample sessions are given below:

Session 1

Enter First Score: 87.6
Enter Second Score: 93.5
Student Grade: A

Enter First Score: -12.1
This is not a valid score. Please enter a positive number or zero.
Enter First Score: 72.1
Enter Second Score: 70.1
Student Grade: C

Enter First Score: 69.4
Enter Second Score: 55.3
Student Grade: Fail

Enter First Score: 98.3
Enter Second Score: 72.2
Student Grade: B
PASSING QUOTA MET

Session 2

Enter First Score: 67.6
Enter Second Score: 71.5
Student Grade: Fail

Enter First Score: 52.1
Enter Second Score: -1
This is not a valid score. Please enter a positive number or zero.
Enter Second Score: 0
Student Grade: Fail
FAILING QUOTA MET



and this is my code so far:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <iostream>
#include <cmath>
using namespace std;

int main()
{
   double firstScore;
   double secondScore;
   double finalScore;

    cout << "Enter First Score: ";
    cin >> firstScore;
    while (firstScore < 0)
    {
      cout << "This is not a valid score. Please enter a positive number or zero." << endl;
      cout << "Enter First Score: ";
      cin >> firstScore;
    }

    cout << "Enter Second Score: ";
    cin >> secondScore;
    while (secondScore < 0)
    {
      cout << "This is not a valid score. Please enter a positive number or zero." << endl;
      cout << "Enter Second Score: ";
      cin >> secondScore;
    }

    finalScore = (firstScore + secondScore) / 2;


       if (finalScore >= 90 && finalScore <= 100)
       {
       cout << "Student Grade: A" << endl;
       }

       else if (finalScore >= 80 && finalScore < 90)
       {
       cout << "Student Grade: B" << endl;
       }

       else if (finalScore >= 70 && finalScore < 80)
       {
       cout << "Student Grade: C" << endl;
       } 

       if (finalScore >= 0 && finalScore < 70)
       {
       cout << "Student Grade: Fail" << endl;
       }



return 0;
}


To be honestly I don't have any clue to do this part:

• Three passing grades have been computed. The program should then print the message “PASSING QUOTA MET” to the console and terminate.

• Two failing grades have been computed. The program should then print the message “FAILING QUOTA MET” to the console and terminate.


Is too confuse for me to make the program loop until the score A, B, C is repeated 3 times and if the score Fail is repeated 2 times.

Thanks in advance for your help!
To begin with, I think you should have counter variables for PASS/FAIL grades such as:
int passCounter;
int failCounter;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <iostream>
#include <cmath>
using namespace std;

int main()
{
   double firstScore;
   double secondScore;
   double finalScore;
   int passingScore = 0;
   int failingScore = 0;
   bool done = false;


    while(!done)
    {

        cout << "Enter First Score: ";
        cin >> firstScore;
        while (firstScore < 0)
        {
          cout << "This is not a valid score. Please enter a positive number or zero." << endl;
          cout << "Enter First Score: ";
          cin >> firstScore;
        }

        cout << "Enter Second Score: ";
        cin >> secondScore;
        while (secondScore < 0)
        {
          cout << "This is not a valid score. Please enter a positive number or zero." << endl;
          cout << "Enter Second Score: ";
          cin >> secondScore;
        }

        finalScore = (firstScore + secondScore) / 2;


           if (finalScore >= 90 && finalScore <= 100)
           {
                cout << "Student Grade: A" << endl;
                passingScore++;
           }

           else if (finalScore >= 80 && finalScore < 90)
           {
                cout << "Student Grade: B" << endl;
                passingScore++;
           }

           else if (finalScore >= 70 && finalScore < 80)
           {
                cout << "Student Grade: C" << endl;
                passingScore++;
           }

           if (finalScore >= 0 && finalScore < 70)
           {
                cout << "Student Grade: Fail" << endl;
                failingScore++;
           }

            if(passingScore == 3)
            {
                cout << "PASSING QUOTA MET" << endl;
                done = true;
            }
            else if(failingScore == 2)
            {
                cout << "FAILING QUOTA MET" << endl;
                done = true;
            }

    }

return 0;
}
I didn't know how to make the counters for the grades...thank you, some new to learn. Works fine now!
Topic archived. No new replies allowed.