Menu
Topics Index
...
`

Inverse trigonometric functions


If you need explanation Read this topic

If you need Answer Take test on this topic

Inverse trigonometric functions
What will be the output of the following program?
public class InverseFunctions {
    public static void main(String[] args) {
        double x = 0.707;
        System.out.print(getDegrees(Math.asin(x)));
        System.out.println(" " + getDegrees(Math.acos(x)) + " " + getDegrees(Math.atan(x)));
    }
    private static double getDegrees(double val) {
        return Math.rint(Math.toDegrees(val));
    }
}

A. 45.0 45.0 45.0
B. 45.0 45.0 35.0
C. Compilation Error
D. Runtime Error
Topic: Java Math Class - java.lang.Math

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

Ans is B...here we use the math class methods to get the Trignomentry values in degrees..

we have getDegree() which is static so that we can call that method wihtout creating objects...

coming to the program here we use the
toDegree() which is usefl to convert given values to equalnt degree this may not be exactly...

here rint() which will convert given value to nearest in value..here 0.7 means it wil give 1...
asin()-->returns the arc sine of an angle
here atan()---returns the arc tan of an angle
acos()-->This method returns the arc cosine of a value

here first asin(x) wil return the value 44.9913 and these value we are passing the rint() which convert this num into 45 and these we are returning as double than it wil b 45.0

next asin(x) wil return the value 45.045 and these value we are passing the rint() which convert this num into 45 and these we are returning as double than it wil b 45.0

atan(x) wil return the value 35.26 and these value we are passing the rint() which convert this num into 35 and these we are returning as double than it wil b 35.0

here above methods are are static so that we  can call those methods with out creating the objects...we can call these methods using the class name(Math)

Posted by Uday Kumar    2014-11-14 12:27:16


ans b.                                                                                                                              The java.lang.Math class serves as Java's math library. All its methods are static and used
directly ; you can't instantiate a Math object.                                                                 Math.rint(a)-Converts double value to integral value in
double format.                                                                                                                 Math.toDegrees(a) converts an angle measured in radians to an approximately equivalent angle measured in degrees.                                                 Math.asin( a) returns the arc sine of an angle, in the range of -pi/2 through pi/2.                                                                                                                                     Math.acos(double a) returns the arc cosine of an angle, in the range of 0.0 through pi                                                                                                                                           Math.atan(a)-This method returns the arc tangent of a value; the returned angle is in the range -pi/2 through pi/2.(PI -- This is the double value that is closer than any other to pi, the ratio of the circumference of a circle to its diameter.)                                                                                                                      coming to this program initially x=assigned with 0.707 double value.                           1sop -----getdegree() cald with Math.asin(x)=0.78524..argument.                               getdegree method returns Math.rint(Math.toDegree(0.78524..))==Math.rint(44.9913(radian value to degree))==45.0                                                                                                                   similarly for 2nd sop----2 time getdegree() cald with cos angle and tan angle,                                       getDegree(Math.acos(x))==getDegree(0.78554..) this func returns                             Math.rint(Math.toDegree(0.78554))==Math.rint(45.008)==45.0.                                           getDegree(Math.atan(x))==getDegree(0.6154) this function returns                           Math.rint(Math.toDegree(0.6154))==Math.rint(35.26)==35.0

Posted by Maheshwari Natarajan    2014-11-14 18:02:12


This dose is now closed and the winners are Uday Kumar,  for 'First Correct Comment', Maheshwari Natarajan,  for 'Best Comment' and Uday Kumar for the 'Popular Comment'. The 'lucky liker' is Varun Kumar. Please login into Merit Campus using facebook, to claim your recharge. Go to http://java.meritcampus.com/earnings to raise the recharge.

Posted by Merit Campus    2014-11-17 02:12:48


© meritcampus 2019

All Rights Reserved.

Open In App