Write a Java program that allow the user to input for the two angles A, and B (all in degrees), and the side a of an oblique triangle. Thereafter, solve for the triangle using laws of sine. Draw the user interface. Note: The sum of the interior angle of a triangle is always equal to 180.
import java.util.*;
//Driver Class
public class Main
{
public static void main(String[] args) {
double a, b, c; // Variables to store Angle values
double side_a, side_b, side_c; // Variables to store side values
Scanner sc = new Scanner(System.in);
System.out.print("Enter Angle A: ");
a = sc.nextDouble();
sc.nextLine();
System.out.print("Enter Angle B: ");
b = sc.nextDouble();
sc.nextLine();
System.out.print("Enter Side a: ");
side_a = sc.nextDouble();
sc.nextLine();
c = 180-(a+b); // Calculating Angle C
double radians1 = Math.toRadians(a);
double radians2 = Math.toRadians(b);
side_b = ((side_a * Math.sin(radians2))/Math.sin(radians1)); // Calculating side b
radians2 = Math.toRadians(c);
side_c = ((side_a * Math.sin(radians2))/Math.sin(radians1)); // Calculating side c
System.out.println("-------------------------------");
System.out.format("Angle C: %.1f", c);
System.out.println();
System.out.format("Side b: %.4f", side_b);
System.out.println();
System.out.format("Side c: %.4f", side_c);
}
}
Comments
Dear aj, please use panel for submitting new questions
Write a Java program to find frequency of each character in a given string. Also display the length and the most frequent among the characters
Leave a comment