Write a C program that solves for any one of the following u
Write a C program that solves for any one of the following unknown parameters of a right triangle, if given two other known parameters from the following list:
Length of the base.
Length of the vertical side.
Length of the hypotenuse.
The angle between the base and the hypotenuse.
The angle between the vertical side and the hypotenuse.
The program should prompt the user to choose which one of the unknowns they want to solve for and take as input into the program the input from the user. The program should then prompt the user which of the two known quantities they have (make sure to include logic to exclude the option of the unknown variable value that they are trying to compute). Then take as input the values of the known quantities and compute the unknown quantity and print the result to the screen.
Dont need until Tuesday
Solution
/* This is not Complete program. It just covers the case when input 1 is unknown */
/* Apply the same logic and keep on increasing the switch cases when input 2 is unknown */
/* For each unknown switch case there will be 6 possible combinations which have to be looked */
#include <iostream>
#include <math>
int printFun(int);
void operations(int);
using namespace std;
int main()
{
int choice;
cout << \"Which unknown you want to find \ Select your choice:\ \ \ \" << endl;
cout<<\"1.Length of the base\"<<endl;
cout<<\"2.Length of the vertical side\"<<endl;
cout<<\"3.Length of the hypotenuse\"<<endl;
cout<<\"4.The angle between the base and the hypotenuse\"<<endl;
cout<<\"5.The angle between the vertical side and the hypotenuse.\"<endl;
cin>>choice;
int s =print(choice);
operations(s);
return 0;
}
int print(int n)
{
int s;
int unk[2];
float unkVal[2];
if(n!=1)
cout<<\"1.Length of the base\"<<endl;
if(n!=2)
cout<<\"2.Length of the vertical side\"<<endl;
if(n!=3)
cout<<\"3.Length of the hypotenuse\"<<endl;
if(n!=4)
cout<<\"4.The angle between the base and the hypotenuse\"<<endl;
if(n!=2)
cout<<\"5.The angle between the vertical side and the hypotenuse.\"<endl;
cin>>s;
cout<<\"\ \ \ Which two value you want to enter\");
cin>>unk[0]>>unk[1];
operations(n,unk,unkVal);
return s;
}
void operations(int n, int unk[], unkVal[])
{
float result;
switch n
{
case 1:
if (unk[0] == 2 && unk[1] == 3)
result = sqrt((unk[1]*unk[1])- (unk[0]*unk[0]));
else if(unk[0]==2 && unk[1] == 4)
{
float a = unk[1] * 3.141592653589793 / 180.0;
float b = cos(a);
result = unk[0] / b;
}
else if (unk[0]==2 && unk[1] == 5)
{
float a = unk[1] * 3.141592653589793 / 180.0;
float b = sin(a);
float temp = 2/b;
result = unk[0] + temp;
}
else if(unk[0]==3 && unk[1] == 4)
{
float a= unk[1] * 3.141592653589793 / 180.0;
float b = cos(a);
result = b * unk[0];
}
else if(unk[0]==3 && unk[1] == 5)
{
float a= unk[1] * 3.141592653589793 / 180.0;
float b = sin(a);
result = b * unk[0];
}
else if(unk[0]==4 && unk[1] == 5)
{
float a= unk[1] * 3.141592653589793 / 180.0;
float b = cos(a);
float a1= unk[0] * 3.141592653589793 / 180.0;
float b1 = sin(a1);
/* Do the maths and same procedure applied */
result = 0.0;
}
cout<<result;
}
}

