Answer to Question #160692 in Java | JSP | JSF for roma

Question #160692

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.


1
Expert's answer
2021-02-04T17:02:36-0500
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);
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Assignment Expert
05.02.21, 22:59

Dear aj, please use panel for submitting new questions

aj
05.02.21, 22:49

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

LATEST TUTORIALS
New on Blog