From 9fd2749974d924d01cdaecba881259b72223e1bd Mon Sep 17 00:00:00 2001 From: "Mr.B" <114798102+MrB141107@users.noreply.github.com> Date: Sat, 4 Nov 2023 14:46:57 +0530 Subject: [PATCH] Create trigonometric_ratios.java A Java program for the users to calculate the trigonometric ratios of triangles. --- trigonometric_ratios.java | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 trigonometric_ratios.java diff --git a/trigonometric_ratios.java b/trigonometric_ratios.java new file mode 100644 index 0000000..c4b37f5 --- /dev/null +++ b/trigonometric_ratios.java @@ -0,0 +1,36 @@ +import java.util.*; + +public class trigonometric_ratios { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + System.out.print("Enter the value of sides A : "); + double a = sc.nextInt(); + System.out.print("Enter the value of sides B : "); + double b = sc.nextInt(); + System.out.print("Enter the value of sides C : "); + double c = sc.nextInt(); + + // Defining the trigonometric ratios sin, cos, tan + double sin = a / c; + double cos = b / c; + double tan = a / b; + + // Defining the trigonometric ratios sec, cosec, cot + double sec = 1 / cos; + double cosec = 1 / sin; + double cot = 1 / tan; + + System.out.println("The value of sin is : " + sin); + System.out.println("The value of cos is : " + cos); + System.out.println("The value of tan is : " + tan); + System.out.println("The value of sec is : " + sec); + System.out.println("The value of cosec is : " + cosec); + System.out.println("The value of cot is : " + cot); + + // Area of triangle using Heron's Formula + double s = (a + b + c) / 2; + double area = Math.sqrt(s * (s - a) * (s - b) * (s - c)); + System.out.println("The area of triangle is : " + area); + + } +}