Errors with triangle coding

I need help with the errors
when I run my compiler I still have about 5 errors and one caution
! expected '}' lines 27-3 times and line 58-4 times
triangle with explanation mark: compairing floating point with ++ or != is unsafe [-Wfloat-equal]
#include <iostream>
#include <math.h>
using namespace std;

#define PI 3.14159265
int main()
{
double side_a, side_b, side_c, angleA, angleB=0, angleC=0;
cout << "Calculate the third side and the two angle of a triangle : ";
cout << endl;
cout << "Enter a: ";
cin >> side_a;
cout << "Enter b: ";
cin >> side_b;
cout << "Enter A: ";
cin >> angleA;
double sinA, sinB;

sinA = sin(angleA * 180 / PI);
sinB = side_a/(side_b*sinA);

if(angleA < 90 ) {
if(side_a < (side_b*sinA)) {
cout << " No solution"<<endl;
return 0;
{
else if( side_a == (side_b*sinA))
{ cout << " One solution" << endl;
angleB = asin(sinB);
angleC = (180 - (angleA+angleB));
side_c = (side_a * sin(angleC * 180 / PI))/sin(angleA * 180 / PI);
cout << "Angle B: "<<angleB << "degrees" << endl;
cout << "Angle C: "<< angleC << "degrees" << endl;
}

else if((side_b > side_a) && (side_a > (side_b*sinA)))
{ cout << " Two solution"<<endl;
angleB = asin(sinB);
angleC = (180 - (angleA+angleB));
side_c = (side_a * sin(angleC*180/PI))/sin(angleA*180/PI);
cout << "Angle B: " << angleB << "degrees" << endl;
cout << "Angle C: "<<angleC << "degrees" << endl;
return 0;
}

if((angleA < 90) && (side_a >= side_b)) {
{ cout << " One solution"<<endl;
angleB = asin(sinB);
angleC = (180 - (angleA+angleB));
side_c = (side_a * sin(angleC*180/PI))/sin(angleA*180/PI);
cout << "Angle B: " << angleB << "degrees" << endl;
cout << "Angle C: " << angleC << "degrees" << endl;
return 0;




1.) Use the code tags.

2.) Make sure you are closing your brackets.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <iostream>
#include <math.h>
using namespace std;

const double PI = 3.14159265;
int main()
{
	double side_a, side_b, side_c, angleA, angleB = 0, angleC = 0;
	cout << "Calculate the third side and the two angle of a triangle : ";
	cout << endl;
	cout << "Enter a: ";
	cin >> side_a;
	cout << "Enter b: ";
	cin >> side_b;
	cout << "Enter A: ";
	cin >> angleA;
	double sinA, sinB;

	sinA = sin(angleA * 180 / PI);
	sinB = side_a / (side_b*sinA);

	if (angleA < 90) {
		if (side_a < (side_b*sinA)) {
			cout << " No solution" << endl;
			return 0;
		}
		else if (side_a == (side_b*sinA))
		{
			cout << " One solution" << endl;
			angleB = asin(sinB);
			angleC = (180 - (angleA + angleB));
			side_c = (side_a * sin(angleC * 180 / PI)) / sin(angleA * 180 / PI);
			cout << "Angle B: " << angleB << "degrees" << endl;
			cout << "Angle C: " << angleC << "degrees" << endl;
		}

		else if ((side_b > side_a) && (side_a > (side_b*sinA)))
		{
			cout << " Two solution" << endl;
			angleB = asin(sinB);
			angleC = (180 - (angleA + angleB));
			side_c = (side_a * sin(angleC * 180 / PI)) / sin(angleA * 180 / PI);
			cout << "Angle B: " << angleB << "degrees" << endl;
			cout << "Angle C: " << angleC << "degrees" << endl;
			return 0;
		}

		if ((angleA < 90) && (side_a >= side_b)) {
			cout << " One solution" << endl;
			angleB = asin(sinB);
			angleC = (180 - (angleA + angleB));
			side_c = (side_a * sin(angleC * 180 / PI)) / sin(angleA * 180 / PI);
			cout << "Angle B: " << angleB << "degrees" << endl;
			cout << "Angle C: " << angleC << "degrees" << endl;
		}

	}
	return 0;
}
Last edited on
Topic archived. No new replies allowed.