Without focusing on law of Cosine, my code bellow attempts to solve for the given sides and angles. If there is also a way, how can I use cin >> to retrieve multiple characters, as you can see I ask the user to input either 'A' or 'S.'
Here is my code and the results
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
char solvefor;
double A; // I used doubles to have specific answers
double a;
double B;
double b;
double C;
double c;
cout << "What are you trying to solve? <ASA(A) or SSA(S)>";
cin >> solvefor;
if (solvefor == 'S')
{
cout << "What is the value of b?" << endl;
cin >> b;
cout << "What is the angle B?" << endl;
cin >> B;
cout << "What is the side c?" << endl;
cin >> c;
C = asin((sin(B)/b) * c); //I would recieve the answers in radians rahter than degrees, any help?
cout << "Your missing C angle is " << C << endl;
A = 180 - C - B;
cout << "Your missing A angle is " << A << endl;
a = (sin(A) *b) / sin(B);
} else {
return 0; //I will work on law of cosine later
}
}
Aucun commentaire:
Enregistrer un commentaire