You are on page 1of 4

#include<iostream>

#include<cmath>

using namespace std;

int main()

// declare sides of triangle a,b and c

float a;

float b;

float c;

// prompt the sides of traingle a,b and c

cout<<"\nEnter the value of side a:";

cin>>a;

cout<<"Enter the value of side b: ";

cin>>b;

cout<<"Enter the value of side c: ";

cin>>c;

// declare angles angleA, angleB, and angleC


float angleA;

float angleB;

float angleC;

cout<<"\nDisplay unknown Angles aplha, beta and gamma "<<endl;

// calculate angleC by law of cosine //law of cosine = a^2 + b2^ - 2ab cos(C) = c^2

angleC = acos(((a*a) + (b*b) - (c*c))/(2*a*b));

cout<<"\nAplha: "<<angleC* (180/3.141592)<<" degrees"<<endl;

// calculate other angles by law of sine // (sin(A) / a) == (sin(?? / b) == (sin(C) / c) // and print angleB and
angle C

angleB = asin((b*sin(angleC))/c);

cout<<"Beta : "<<angleB* (180 / 3.141592) <<" degrees"<<endl;

angleA = asin((a*sin(angleC))/c);

cout<<"Gamma: "<<angleA* (180 / 3.141592)<<" degrees"<<endl;

// now test for Mollweide's Equation

cout<<"\nTest for Mollweide's Equation : \n";

// calculate Lhs
float Ihs;

Ihs = (a-b)/c;

Ihs = round( Ihs * 100000.0) /100000.0;

cout<<"\nLeft Hand Side: "<<Ihs<<endl;

// calculate Rhs

float rhs;

rhs = sin((angleA - angleB)/2) / cos(angleC/2);

rhs = round(rhs * 100000.0)/100000.0;

cout<<"Right Hand Side: "<<rhs<<endl;

// check and prove lhs and rhs

if(Ihs == rhs)

cout<<"\nProved Mollweide's Equation!!"<<endl;

else

{
cout<<"\nMollweide's Equation not proved !!" <<endl;

return 0; }

You might also like