/*************************************************

On a distant wall, you sight a mark of known
height at angle theta1 from the ground.  You sight
the top of the building sights at angle theta2
from the ground.  Write a program that takes in
these two angles in degrees and the height of the 
mark in feet & inches (e.g. 6'4") and returns the
height of the building in feet and inches (no
fractions or decimals).  If H is the height of the
known mark, then the building height is given by:

                          tan(theta2)
    Building height = H * -----------
                          tan(theta1)

*************************************************/
#include <iostream>
#include <cmath>

int getinches();
double deg2rad(double);
void writeinches(int);

int main()
{
  // Get height H in inches
  cout << "Height of mark? ";
  int H = getinches();

  // Get angles theta1 & theta2 in degrees
  double theta1, theta2;
  cout << "Theta1? ";
  cin >> theta1;
  cout << "Theta2? ";
  cin >> theta2;

  // Calculate Building Height in inches
  double T1 = deg2rad(theta1), T2 = deg2rad(theta1);
  int BH = H*tan(T2)/tan(T1);

  // Write out building height
  cout << "Building height is ";
  writeinches(BH);
  cout << endl;

  return 0;
}

/********************************
 ** Read distance in x'y" format
 ** and return the dstance in
 ** inches.
 ********************************/
int getinches()
{
  int f,i;
  char c;
  cin >> f >> c >> i >> c;
  return 12*f + i;
}

/********************************
 ** convert angle in degrees to
 ** angle in radians
 ********************************/
double deg2rad(double a)
{
  return a/180*3.14159;
}

/********************************
 ** Write L inches to screen in
 ** y'x" format
 ********************************/
void writeinches(int L)
{
  int f = L/12, i = L % 12;
  cout << f << '\''
       << i << "\""
       << endl;
}