So I'm somewhat new to programming and I have a assignment in which I have to verify if the numerator entered by the user is a decimal, instead of a integer. If it is, then I throw an exception...the thing is I don't really know how to do it because as you all know, it doesn't matter if the variable is integer, if I input 3.49...it will be shortened to 3. So how can I know if it was decimal?
int main()
{
int numerator,denominator;
try
{
cout << "Input the numerator : " ;
cin >> numerator;
cout << "Input the denominator : " ;
cin >> denominator;
if (denominator == 0)
throw denominator;
else
cout << numerator << '/' << denominador
<< "=" << double(numerator)/double(denominator) << endl;
}
catch(int e)
{
cout << " The value of the denominator " << e << " is invalid. " <<endl;
system("PAUSE");
}
return EXIT_SUCCESS;
}