- #1
obeying
- 8
- 0
Simple geometry can compute the height of an object from the object's shadow length and shadow angle using the formula: tan(angleElevation) = treeHeight / shadowLength. Given the shadow length and angle of elevation, compute the tree height.
What I have so far:
import java.util.Scanner;
import java.lang.Math;
public class TreeHeight {
public static void main(String [] args) {
double treeHeight = 0.0;
double shadowLength = 0.0;
double angleElevation = 0.0;
angleElevation = 0.11693706; // 0.11693706 radians = 6.7 degrees
shadowLength = 17.5;
treeHeight = shadowLength * tan(angleElevation);
System.out.print("Tree height: ");
System.out.println(treeHeight);
return;
}
}
Error that I'm getting:
TreeHeight.java:14: cannot find symbol
symbol : method tan(double)
location: class TreeHeight
treeHeight = shadowLength * tan(angleElevation);
1 error
What I have so far:
import java.util.Scanner;
import java.lang.Math;
public class TreeHeight {
public static void main(String [] args) {
double treeHeight = 0.0;
double shadowLength = 0.0;
double angleElevation = 0.0;
angleElevation = 0.11693706; // 0.11693706 radians = 6.7 degrees
shadowLength = 17.5;
treeHeight = shadowLength * tan(angleElevation);
System.out.print("Tree height: ");
System.out.println(treeHeight);
return;
}
}
Error that I'm getting:
TreeHeight.java:14: cannot find symbol
symbol : method tan(double)
location: class TreeHeight
treeHeight = shadowLength * tan(angleElevation);
1 error