/*****************************************************************
** Height - program to demonstrate method in Math class
**
** This program computes the height of a building given two
** measurements: the distance to the building and a line-of-sight
** angle taken from this distance to the roof of the building.
** For this example,
**
**    distance = 30 meters
**    angle    = 22 degrees
**
** Since the Math.tan method requires an radian measure for the
** angle, the Math.toRadians() method is used first to convert
** the angle.  The height of the building is then computed
** from the formula
**
**    height = distance * tan(aRadians)
**
** A sample dialog follows:
**
**    C:\>java Height
**    Enter distance (meters) to building: 30
**    Enter line-of-sight angle (degrees) to roof: 22
**    Building is 12.120786775054704 meters high
**
** (c) Scott MacKenzie, 2000                             
******************************************************************/
import java.io.*;

public class Height
{
   public static void main(String[] args) throws IOException
   {
      BufferedReader stdin =
         new BufferedReader(new InputStreamReader(System.in), 1);

      // Input distance to building
      System.out.print("Enter distance to building: ");
      double distance = Double.parseDouble(stdin.readLine());

      // Input line-of-sight angle to top of building
      System.out.print("Enter line-of-sight angle (degrees) to roof: ");
      double angle = Double.parseDouble(stdin.readLine());

      // Calculate height of building
      double aRadians = Math.toRadians(angle);
      double height = distance * Math.tan(aRadians);

      // print height
      System.out.println("Building is " + height + " meters high");
   }
}

