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


This Java program computes the trigonometric arc tangent of a given degree value. The program does the following:

  • Import the java.util package which provides classes for handling user input.
  • Declare a public class named Trigonometric_ArcTangent.
  • Declare a public static void method named main which accepts an array of string objects as its parameter.
  • Inside the main method, create a new Scanner object to read user input.
  • Declare a double variable named deg and initialize it to 0.
  • Prompt the user to enter a degree value and read it using the Scanner object. Assign the user input to the deg variable.
  • Convert the deg value to radians using the Math.toRadians() method and store the result in a rad variable.
  • Compute the trigonometric arc tangent of rad using the Math.atan() method and display the result on the console using the System.out.print() method.
  • Close the Scanner object.

The Math.atan() method takes a radian value as its argument and returns the trigonometric arc tangent of that value in radians. The Math.toRadians() method is used to convert a degree value to its equivalent in radians.

Source Code

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

Output

Enter The Degree : 12
Trigonometric arc Tangent is : 0.2064553175808596

Example Programs