/*****************************************************
Name: Area of triangle Calculator
Copyright: BCS-1A
Author: Muhammad Hussnain Imtiaz
Date: 21/12/11 23:46
Description: Porgram to calculate area of triangle
******************************************************/
# include <iostream>
# include <conio.h>
# include <cmath>
using namespace std ;
int main ()
{
// local declaration
double a=0.0,
b=0.0,
c=0.0,
area=0.0,
s=0.0,
;
cout << " Area of Triangle calculater " << endl << endl ;
cout << " Enter 'y' to continue and 'n' to exit :" ;
while (getche() != 'n')
{
system("CLS");
cout << endl << endl;
cout << " Please Enter the side-1 of Triangle :" ;
cin >> a ;
cout << " Please Enter the side-2 of Triangle :" ;
cin >> b ;
cout << " Please Enter the side-3 of Triangle :" ;
cin >> c ;
if( a+b>c && b+c>a && c+a>b )
{
s=(a+b+c)/2.0 ;
area=sqrt ((s*(s-a)*(s-b)*(s-c))) ;
cout << "\n\n\n The Area of Triangle is: " << area ;
if (a==b && b==c)
{
cout << "\n\nAll Sides of Triangle are equal in length" ;
}
if (a>b && a>c)
{
cout << "\n\n Side-1 is Greater than other sides" ;
}
if (b>a && b>c)
{
cout << "\n\n Side-2 is Greater than other sides" ;
}
if (c>a && c>b)
{
cout << "\n\n Side-3 is Greater than other sides" ;
}
if (a<b && a<c)
{
cout << "\n\n Side-1 is Less than other sides" ;
}
if (b<a && b<c)
{
cout << "\n\n Side-2 is Less than other sides" ;
}
if (c<a && c<b)
{
cout << "\n\n Side-3 is Less than other sides" ;
}
cout << "\n\n\n Enter 'y' to continue and 'n' to exit :" ;
}// End of if
else
{
cout << "\n Triangle is not Constructed" ;
cout << "\n\n\n Enter 'y' to continue and 'n' to exit :" ;
}//end of else
}// end of while
system ("CLS");
cout << "\n\n\n\n\n\n\n\n\n\n\n\n "
<< " Created By:Mohammad Hussnain Imtiaz " ;
getch ();
return 0;
}// end of main function
No comments:
Post a Comment