#include<iostream>
using namespace std;

int main()
{
	char choice;
	double area, radius, length, width, base, height;
	const double PI = 3.14159;
	char input='y';
	

		cout << "Geometry Calculator \n\n";
		cout << "1. Calculate the Area of a Circle \n";
		cout << "2. Calculate the Area of a Rectangle \n";
		cout << "3. Calculate the Area of a Triangle \n";
		cout << "4. Quit \n\n";
		
		while(input=='y')
		{
		
			cout << "Enter your choice (1-4): ";
			cin >> choice;
	
		switch(choice)
		{
			case '1': cout<<"Enter the radius of a circle\n";
					cin>>radius;
					while (radius<0)
					{
							cout<<"Invalid Number\n";
							cout<<"Please enter positive number\n";
							cout<<"Enter the radius of a circle\n";
							cin>>radius;
					}
			 		area=PI*radius*radius;
					cout<<"Area of a circle is: "<<area<<endl;
					break;
				
			case '2': cout<<"Enter the length and width of the rectangle\n";
					cin>> length>> width;
					while ((length<0)||(width<0))
					{
							cout<<"Invalid Number\n";
							cout<<"Please enter positive number\n";
							cout<<"Enter the length and width of the rectangle\n";
							cin>> length>>width;
							
					}
					area=length*width;
					cout<<"Area of rectangle is: "<< area<<endl;
					break;
				
			case '3':cout<<"Enter the length of the triangle's base and its height\n";
			  	    cin>>base>>height;
			  	    while ((base<0)||(height<0))
					{
							cout<<"Invalid Number\n";
							cout<<"Please enter positive number\n";
							cout<<"Enter the length of the triangle's base and its height\n";
							cin>>base>>height;
						
					}
			  	    area=base*height*.5;
			  	    cout<<"Area of triangle is: "<<area<<endl;
			   	    break;
			   
			case '4':cout<<"Thanks for using geometry calculator";
					return 0;
		
			default:cout<<"ERROR! Invalid choice\n";
					break;
		}
		cout<<"\nDo you want to continue y/n : ";
		cin>>input;
		
	}
			return 0;

	}
	 
	

