Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a C++ program to display a table of values for side B, side H, angle a (in

ID: 3926231 • Letter: W

Question

Write a C++ program to display a table of values for side B, side H, angle a (in degrees) and alpha (in degrees) for the right triangle shown. Use a for loop to calculate H, alpha and beta as side B from 2 m to 20 m in 2 m increments. The output should be a table of values for B, H, alpha and beta similar to the one shown below (no lines are required). Use 0 digits after the decimal point for B, 3 digits after the decimal point for H, and 2 digits after the decimal point for alpha, and beta. Turn in a printout of the program and a printout of the results. The table should be nicely aligned.

Explanation / Answer

#include<iostream>

#include<cmath>

using namespace std;

int main()

{

cout<<". B(m) H(m) alpha. Beta)";

for(int i=2;i<=20;i=i+2)

{

disp(i);

}

return 0;

}

void disp(int r)

{

double a=10.0;

double b=double(r);

double alpha=atan((a/b)*(180/3.14));

double beta=atan((b/a)*(180/3.14));

double h=a/sin(alpha);

cout<<" "<<h<<" "<<alpha<<" "<<beta;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote