I have had sin,cos,tan in school but I don't really know how to use them in programming. Could someone give me an example about how you calculate the X in the triangle below.

Using a little bit of trigonometry, you can set up an equation:

Solving this for x, you get

You can convert this almost directly into Java using the Math class:

The Math class also provides methods for cosine, tangent, and other nifty mathematical functions. See the link provided above for the Javadocs for this class.