Error message only works once. Do I need to do a Do while loop?

Brand new to programming. Stuck on my project, apparently our class is not on the "do while" looping chapter yet, even though our project calls for it.

Here's the problem:

Enter Exam 1 score 1: -2
Exam score cannot be lower than 0 or higher than 100.
Please re-enter score: 200
Enter Exam 2 score:


It's supposed to do

Enter Exam 1 score: -2
Exam score cannot be lower than 0 or higher than 100
Please re-enter score: 200
Invalid entry. Program will now quit.
Press any key to continue...



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 
    //************************  Enter Exam 1
    
    cout << "Please enter score for Exam 1: ";
        cin >> exam_1;
    
    // *********************** error message

    
    if (exam_1 < 0 || exam_1 > 100 ) {
        
        
        cout << "Exam score cannot be lower than 0.0 or higher than 100.0. Please re-enter score: ";
        cin >> exam_1;
        
    }


I attempted to do a do while loop but I couldn't break; it. I got frustrated and deleted it.
Last edited on
¿can you do a pseudocode or a diagram flow of the solution?
Topic archived. No new replies allowed.