Ask Question

Java Program for lengths of the sides of a triangle to compute the area using the given equation LaTeX: Area/:=/:/sqrt{s/left (s-a/right) / left (s-b/right) / left (s-c/right) }

+2
Answers (1)
  1. 2 February, 22:49
    0
    import java. util. Scanner;

    public class Area

    {

    public static void main (String[] args) {

    double a, b, c, s, area;

    Scanner input = new Scanner (System. in);

    System. out. print ("Enter three sides of the triangle: ");

    a = input. nextDouble ();

    b = input. nextDouble ();

    c = input. nextDouble ();

    s = (a + b + c) / 2;

    area = Math. sqrt (s * (s-a) * (s-b) * (s-c));

    System. out. print ("The area of triangle = " + area);

    }

    }

    Explanation:

    Define variables for the sides, s, and area.

    Ask the user for the side values using Scanner object.

    Use the given formula to calculate s.

    After calculating s, use the formula to calculate area.

    Print the value of area.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Java Program for lengths of the sides of a triangle to compute the area using the given equation LaTeX: Area/:=/:/sqrt{s/left (s-a/right) / ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers