Triangle's sides and angles with cosine, sine theory, top-up design

Hello. I'm stuck with this task. There is triangle, you input 2 sides a, b and gamma angle (angle between them) in degrees. I need to find alpha angle and output it in degrees, minutes, seconds. There should be convert from degree to radian and radian to degree . Program must be written in top-up design. Like function in function. I don't exact know how it is designing. If you can, please, correct my code. I'm not sure is that design good plus that functions is rule to use.

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
60
61
#include <iostream>
#include <cmath>

using namespace std;

double LaipRad(double laip); //laip = degrees
double RadLaip(double rad);
double krastine(double a, double b, double gama); //krastine = side
double kampas(double a, double b, double beta);// kampas = angle
void LaipMinSek(double alfa); //deg min sek
int main()
{
    setlocale(LC_ALL, "Lithuanian");
    double laip;
    cout<<"Įvesk kampą 'gamma'\n";
    cin>>laip; //function requires 'laip' so I guess I need to do it ?
    laip;
    LaipRad(laip);
    return 0;
}
double LaipRad(double laip){
    double a, b, gamma, pi;
    pi=3,14;
    gamma=laip*pi/180;
    cout<<"Įvesk a ir b kraštinių ilgius centimetrais\n";
    cin>>a>>b;
    krastine(a, b, gamma);
return 0;
}

double krastine(double a, double b, double gamma){
double beta;
beta=gamma;
a=sqrt(a*a+b*b-2*b*a-gamma);
kampas(a, b, beta);
return 0;
}
double kampas(double a, double b, double beta){
    double gamma, rad, alfa;
    gamma=beta;
    beta=beta*b/a; //proportion, sin theory maybe
    rad=beta;
    alfa=180-gamma-RadLaip(rad);
    LaipMinSek(alfa);
return 0;
}
double RadLaip(double rad){
double pi, alfa, beta;
pi=3,14;
beta=rad*180/pi;
return beta;
}
void LaipMinSek(double alfa){ // I guess this is not working too
double min, sek;
int laip;
laip=alfa;
min=int(alfa-laip)*60;
sek=(alfa-laip-min/60)*3600;
cout<<"Alfa kampas: \n"<<laip<<"° "<<min<<":"<<sek;
}


Last edited on
Note that 3,14 does not mean what you think it means. Because of the meaning of the comma operator in C++, this expression actually evaluates to 14. 3.14 is what you meant.
Topic archived. No new replies allowed.