Hi -- After lots of searching I cant seem to find an answer (well one that I understand at least..)
I want to make the variables wobstacle, waisle, and wturn ONLY numbers where a user cannot input a letter and break the program. I was thinking of something along the lines of if wobstacle ! isnan then return them back to the beginning...But the syntax is incorrect and doesn't seem as though I can use it this way...any help?
Thanks
#include <iostream.h>
#include <math.h>
int main()
{
double wobstacle, //Width of obstacle
waisle, //Width of aisle
wturn; //Width of turn
bool flag;
//Calculate if the turn meets US
flag=true;
cout << endl << "Please enter the width of the OBSTACLE, AISLE, and "
<< "TURN in inches. (With spaces inbetween): ";
cin >> wobstacle >> waisle >> wturn;
while ( flag == true )
{
//Check for not a number:
if ( wobstacle ! nan && waisle ! nan && wturn ! nan )
{
flag=false;
}
else
cout<< endl << "Please enter a number";
cin >> wobstacle >> waisle >> wturn;
flag=true;
}
if(wobstacle >= 48 && waisle >= 36 && wturn >= 36
|| wobstacle < 48 && waisle >= 42 && wturn >= 48)
{
cout << "The design specifications meet the UFAS requirements";
}
else
cout << "The design specifications do not meet the UFAS requirements";
system("pause");
return 0;
}