Write a Java program to Find the trigonometric arc sine of an angle


This is a Java program that calculates the trigonometric arc sine of an input angle in degrees using the Math.asin() function. Here's how the code works:

  • The program starts by importing the java.util package which includes the Scanner class that we will use to read user input from the console.
  • The program defines a public class called Trigonometric_ArcSine.
  • Within the Trigonometric_ArcSine class, the program defines the main method, which is the entry point of the program.
  • Inside the main method, a new instance of the Scanner class is created and assigned to the variable X.
  • The program prompts the user to enter an angle in degrees by printing the message "Enter The Degree : " to the console.
  • The user's input is read as a double and assigned to the variable deg.
  • The program converts the angle from degrees to radians using the Math.toRadians() function, and assigns the result to the variable rad.
  • Finally, the program calculates the trigonometric arc sine of the angle in radians using the Math.asin() function, and prints the result to the console along with the message "Trigonometric arc Sine is : ".

Note that the Math.asin() function returns the result in radians, so the output of the program will be in radians even though the input is in degrees. If you want the output to be in degrees, you'll need to convert the result back using the Math.toDegrees() function.

Source Code

import java.util.*;
public class Trigonometric_ArcSine
{
	public static void main(String[] args)
	{
		Scanner X = new Scanner(System.in);
		double deg = 0;
 
		System.out.print("Enter The Degree : ");
		deg = X.nextDouble();
 
		double rad = Math.toRadians(deg);
		System.out.print("Trigonometric arc Sine is : " + Math.asin(rad));
	}
}

Output

Enter The Degree : 190
Trigonometric arc Sine is : NaN

Example Programs