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


  • The code starts with importing the java.util package that includes the Scanner class, which is used to read user input from the console.
  • The class Trigonometric_Sine is defined with the public access modifier, which means that it can be accessed by any other class in the program.
  • The main method is defined with the public static access modifiers. It is the entry point of the program and is called automatically by the Java Virtual Machine (JVM).
  • A new Scanner object is created using the System.in parameter, which tells the Scanner to read input from the console.
  • A double variable deg is declared and initialized to 0.
  • A message is printed to the console asking the user to enter the degree value.
  • The input is read using the nextDouble() method of the Scanner class and is assigned to the deg variable.
  • The Math.toRadians() method is used to convert the degree value to radians.
  • The Math.sin() method is used to calculate the trigonometric sine value of the input in radians.
  • The result is printed to the console using the System.out.print() method.

Source Code

import java.util.*;
public class Trigonometric_Sine
{
	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 Sine is : " + Math.sin(rad));
	}
}

Output

Enter The Degree : 156
Trigonometric Sine is : 0.40673664307580043

Example Programs