So, I'm working on a fraction calculator to add, subtract, divide and multiply. Currently on the part where it's asking for the user to input their fractions. My professor states this on the assignment sheet: "A valid sign will be ‘+’ or '-', a valid whole part or numerator will be any non-negative integer value, and a valid denominator will be any positive integer value."
So, my question is this...how can I get it to detect whether a user has entered in a mixed number (ex: 3 4/7) or a normal fraction (4/7). I can get it to read a regular fraction fine, but where would I start to check the data they enter to see which it is?
int main(void)
{
int num = 0;
int den = 0;
char dummy;
cout << "Please enter in a fraction: " ;
cin >> num >> dummy >> den;
cout << num << "/" << den;
system("pause");
return 0;
}