.
. .
..
C..
.. A
. .
.T.
......................
B
sin(T) = A / C
csc(T) = C / A (= 1 / sin(T))
cos(T) = B / C
sec(T) = C / B (= 1 / cos(T))
tan(T) = A / B (= sin(T) / cos(T))
cot(T) = B / A (= 1 / tan(T))
Checkout this class: http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Math.html
> but the result was incorrect
> please try that and give me your opinions
> thanks for all
I can't: your code won't compile.
The argument of the Math.sin(...) function must be an angle in radians.
So if my example would be A=3, B=4 and C=5 then T ~= 36.9 degrees and in radians T ~= (Pi / (180.0 / 36.9)).
> Where I come from we do trig with numbers, not java.lang.Strings.
LOL!
WTF? You've got the example of java.lang.Math right in front of you. Isn't emulation the sincerest form of flattery? Write your functions to look like the java.lang.Math ones:
public class MyMathFunctions
{
public static final double csc(double angleInRadians)
{
return 1.0/Math.sin(angleInRadians);
}
public static final double sec(double angleInRadians)
{
return 1.0/Math.cos(angleInRadians);
}
public static final double cot(double angleInRadians)
{
return 1.0/Math.tan(angleInRadians);
}
}
%
Thanks for all members ::
but i want to point that i prgramed this functions , see the code
of that , but the result is incorrect
example:
the correct answers must be
csc 0.5=30
sec 0.5=60
cot 1.0=45
but in this code the results don't give this answers
The results that displayed as follow
csc 0.5=2.08.........
sec 0.5=1.13.........
cot 1.0=0.64.........
import javax.swing.*;
public class MyMathFunctions
{
public static void main(String [] args)
{
MyMathFunctions F=new MyMathFunctions();
String output;
output="Csc : "+F.csc(0.5)+"\nSec : "+F.sec(0.5)+"\n Cot : "+F.cot(1);
JOptionPane.showMessageDialog(null,output);
}
public static final double csc(double angleInRadians)
{
return 1.0/Math.sin(angleInRadians);
}
public static final double sec(double angleInRadians)
{
return 1.0/Math.cos(angleInRadians);
}
public static final double cot(double angleInRadians)
{
return 1.0/Math.tan(angleInRadians);
}
}
> example:
> the correct answers must be
> csc 0.5=30
> sec 0.5=60
> cot 1.0=45
Wrong. Again: the argument of these functions are radians. You obviously don't know what a radian is. You really need to brush up your trigonometry.
> but in this code the results don't give this answers
> The results that displayed as follow
>
> csc 0.5=2.08.........
> sec 0.5=1.13.........
> cot 1.0=0.64.........
That is correct.
Tip: Google also has a nice calculator function:
[url=http://www.google.com/search?hl=en&q=csc%280.5%29&btnG=Google+Search]csc(0.5) according to Google[/url]
> example:
> the correct answers must be
> csc 0.5=30
> sec 0.5=60
> cot 1.0=45
No, but
arcsin 0.5 = 30?br>arccos 0.5 = 60?br>arctan 1.0 = 45?br>
1-1
cosec(x) = - = (sin(x))
sin(x)
-1
arcsin(x) = sin (x)
Which function do you want?
Pete