Example from a OOP Book
/*
* Chapter 3 Sample Program: Estimate the Pole Height
* File: Ch3PoleHeight.java
*/
import java.text.*;
import java.util.*;
class Ch3PoleHeight
{
public static void main(String[] args)
{
double height; //height of the pole
double distance; //distance between A and B
double alpha; //angle measured at point A
double beta; //angle measured at point B
double alphaRad; //angle alpha in radians
double betaRad; //angle beta in radians
Scanner scanner = new Scanner(System.in);
scanner.useDelimiter(System.getProperty("line.separator"));
//Get three input values
System.out.print("Angle alpha (in degrees):");
alpha = scanner.nextDouble();
System.out.print("Angle beta (in degrees):");
beta = scanner.nextDouble();
System.out.print("Distance between points A and B (ft):");
distance = scanner.nextDouble();
//Compute the height of the tower
alphaRad = Math.toRadians(alpha);
betaRad = Math.toRadians(beta);
height = (distance * Math.sin(alphaRad) * Math.sin(betaRad)) /
Math.sqrt(Math.sin(alphaRad + betaRad) *
Math.sin(alphaRad - betaRad));
DecimalFormat df = new DecimalFormat("0.000");
System.out.println("Estimating the height of the statue"
+ "\n\n"
+ "Angle at point A (deg): " + df.format(alpha) + "\n"
+ "Angle at point B (deg): " + df.format(beta) + "\n"
+ "Distance between A and B (ft): " + df.format(distance) + "\n"
+ "Estimated height (ft):" + df.format(height));
}
}
Cannot get the above program to work? Please can anyone help me!!!!

