The Computer Science Department 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 to the next program. Your program should have the following structure: Declare two integer variables programsDone and result. Validate the data captured for the two variables using a while loop. The loop should be repeated until the value of result is greater than or equal to 50 and the value of programsDone is greater than or equal to 5. 20 Display a message like "Good! You can now proceed to the next exercise"
#include <iostream>
using namespace std;
int main(){
int programsDone = 0, result = 0;
bool flag = true;
while(flag){
if(programsDone < 5){
cout<<"Enter programsDone: ";
cin>>programsDone;
}
if(result < 50){
cout<<"Enter result: ";
cin>>result;
}
flag = result < 50 || programsDone < 5;
}
cout<<"Good! You can now proceed to the next exercise";
return 0;
}
Comments
Wow. Thank you very much. I have been struggling with the above for months now and opted to ask you as an expect and you just made it simple for me. Thank you very much, keep up the good work
Leave a comment