There are two things which I didn't or could not achieve with using maths.cos() from Java.

First - When I calculate cos90 or cos270, it gives me absurb values. It should be 0. Meaning it cannot calculate if the angle lies on X axis.

I tested with 91 or 271, gives a near 0 which is correct.

Second - I was figuring how do I include the number of terms to be calculated with my Cosine formula....

Lastly, I am using JFrames as my GUI and I can only properly exit from my menu bar. And not from the X button at top RH corner.

I would appreciate hints or guidance in solving the above 3 issues. Thank you so much people! :)