Reputation: 47
Ive been given this assignment and one question I don't understand what im doing wrong exactly.
Question: The Computer Science Depatment follows certain criteria when a student learns to program. A number of programming exercises must be worked through. To proceed to the next exercise a student has to obtain a mark of 50% or more and must have completed 5 or more program runs. You are requested to write a program to validate if a student can proceed.
#include <iostream>
using namespace std;
int main()
{
int Programsdone;
int Result;
while (Result >= 50 || Programsdone >= 5)
{
cout << " Please enter your mark obtained :" << endl;
cin >> Result;
Programsdone++;
}
cout << "Good! You can now proceed to the next exercises." << endl;
return 0;
}
The data must be validated with a while loop and must be repeated until Result is greater than or equal to 50 AND the value of Programsdone is greater than or equal to 5.
My problem is i cant seem to get the loop to stop correctly and im hopelessly lost with it. Any help would be great!
Upvotes: 1
Views: 86
Reputation: 4333
#include <iostream>
using namespace std;
int main() {
int Programsdone = 0;
int Result;
while (Programsdone < 5) {
cout << " Please enter your mark obtained :" << endl;
cin >> Result;
if ( Result >=50 ) Programsdone++;
}
cout << "Good! You can now proceed to the next exercises." << endl;
return 0;
}
I think that's what you mean.
Upvotes: 1