this is a part of my programme
Code:
class Impedence
{
protected:
int R1, R2, X1, X2;
public:
void enterNum(void);
};
void Impedence::enterNum(void)
{
cout<<"Enter real part of impendence A: ";
cin>>R1;
cout<<"Enter imaginary part of impedence A: ";
cin>>X1;
cout<<"Enter real part of impedence B: ";
cin>>R2;
cout<<"Enter imaginary part of impedence B: ";
cin>>X2;
}
how do i modify it such that the user can only enter positive integer?
invalid input will stop the next statement and return to the first.
for eg. if the user entered alphabet "a" or any other alphabet it will show "Please enter an integer value!" the programme will then loop back to the first cout.