-1

I had a problem that I had to create a menu that asks for user's input and depending on that input it will calculate area of circle, rectangle, or a triangle. I got that part worked out but the last part of the problem is "Do Not accept negative values for the user's input". How would I incorporate that into my problem? Here is my code.

```
if (num < 1 || num > 4)
{
cout << "You have entered an invalid choice, Please try again\n";
}
else if (num == 1)
{
int rad;
double pie = 3.14159;
cout << "Please enter in the Radius of the Circle ";
cin >> rad;
double area = pie * (rad * rad);
cout << "The Area of the Cirle is " << area << endl;
}
else if (num == 2)
{
int len, wid;
cout << "Please enter the length of the Rectangle ";
cin >> len;
cout << "Please enter the width of the Rectangle ";
cin >> wid;
double area = wid * len;
cout << "The Area of the Rectangle is " << area << endl;
}
else if (num == 3)
{
int base, hei;
cout << "Please enter in the Base of the Triangle ";
cin >> base;
cout << "Please enter in the Height of the Triangle ";
cin >> hei;
double area = (.5 * base) * hei;
cout << "The Area of the Triangle is " << area << endl;
}
else if (num == 4)
{
cout << "You have opted out of the program, have a nice day!\n";
}
return 0;
}
```

*Edited 3 Years Ago by Dani*: Formatting fixed