> i already used this method but didn't get right answer
>
> result = Math.sin(getNumberInDisplay());
> result = result*(3.14)/180;
> displayResult(result);
>
> this is code ............ what should i do?
Read the API docs for the Math class again: it has to useful methods:
toDegrees and toRadians. They go like this:double degrees= Math.toDegrees(radians);
double radians= Math.toRadians(degrees);
kind regards,
Jos
>> i also used these methods but didn't get right asnwer :(
well its not us or the math library. there must be something wrong
with your code other then the conversion.
public class DegreesToRadians{
public static void main(String[] args) {
double degrees = 180;
System.out.println("Degrees: " + degrees);
double radians = Math.toRadians(degrees);
System.out.println("Degrees: " + radians);
}
}
> i already used this method but didn't get right
> answer
>
> result = Math.sin(getNumberInDisplay());
> result = result*(3.14)/180;
> displayResult(result);
>
> this is code ............ what should i do?
Learn some mathematics to start with.
The result of the sine function is not an angle, it's the sine of the angle.
You only apply that transformation from radians to degrees and back to the angle, not the sine of the angle.
If you want to get an angle out of a trig function, you usually have to apply the inverse.
What does that "getNumberinDisplay()" method return? (Bad name - most unclear.) If it's an angle, that's the thing that needs to be transformed. Math trig functions usually deal with radians.
I'm betting this is the right thing:
double angle = Math.toRadians(getNumberInDisplay());
doube result = Math.sine(angle);
System.out.println("angle (radians): " + angle + " sin(angle): " + result);
%