P
P
PRAIT2019-06-11 18:21:22
Java
PRAIT, 2019-06-11 18:21:22

Is a program correctly written that calculates and displays the area of ​​a triangle if its sides are known?

Hello everyone, actually a subject.
There is a variable with values

double a = 0.4;
double b = 0.3;
double c = 0.5;

It is necessary to implement a program according to Heron's formula with the formula Math.sqrt
That's what happened to me
package pack;

public class two {

  public static void main(String[] args) {
    double a = 0.4, b = 0.3, c = 0.5;
    
    double d = Math.sqrt(a * a + b * b + c * c);
    System.out.println("Площадь треугольника равна " +d);
  }
}

Is the code implemented correctly? Thank you for your time!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Boris Korobkov, 2019-06-11
@BorisKorobkov

Not right.
Heron's formula is not the root of the sum of the squares of the sides. Open your math textbook.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question