prompt for user input between 0 to 100

i want limiting the user input by only key in the mark between
0 to 100.
this is my coding:
#include <iostream>
using namespace std;
class Student{
public:
char name[10];
double test1,test2,assignment1,assignment2;
double totalmark,average;
void TotalMark();
void Average();
void Grade();
};

void Student::TotalMark(){
totalmark=test1+test2+assignment1+assignment2;
cout<<"Total mark : "<<totalmark<<endl;
}
void Student::Average(){
average=totalmark/4;
cout<<"Average mark : "<<average<<endl;
}
void Student::Grade(){
if (average>=80 && average <=100)
cout<<"Grade A"<<endl<<endl;
else if(average>=60 && average <=79)
cout<<"Grade B"<<endl<<endl;
else if(average>=50 && average <=59)
cout<<"Grade C"<<endl<<endl;
else if(average>=0 && average <=49)
cout<<"Grade F"<<endl<<endl;

}

int main(){
Student inti[5];
for(int i=0;i<5;i++){
cout<<"Enter name: ";
cin>>inti[i].name;

cout<<"Enter your mark for Test 1: ";
cin>>inti[i].test1;
cout<<"Enter your mark for Test 2: ";
cin>>inti[i].test2;
cout<<"Enter your mark for Assignment 1: ";
cin>>inti[i].assignment1;
cout<<"Enter your mark for Assignment 2: ";
cin>>inti[i].assignment2;

inti[i].TotalMark();
inti[i].Average();
inti[i].Grade();
}
return 0;
}
Use a loop while getting input from the user - prompt the user for another input if it is less than 0 or more than 100.

1
2
3
while (input < 0 || input > 100)
{
    //ask the user for input again 

Topic archived. No new replies allowed.