Heron公式
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Heron公式相关的知识,希望对你有一定的参考价值。
Java Heron's formula
import java.util.Scanner; public class HeronsFormula { double sidea = input.nextDouble(); double sideb = input.nextDouble(); double sidec = input.nextDouble(); System.out.println("The lengths of the sides of your triangle are: " + ' ' + sidea + ' ' + sideb + ' ' + sidec); System.out.println("The area of your triangle using Heron's Formula is: " + getArea(sidea,sideb,sidec)); } public static double getArea(double a, double b, double c) { //method calculates area double s = (a + b + c)/2.0; //s = perimeter/2 double x = ((s) * (s-a) * (s-b) * (s-c)); //herons formula return area; } }
以上是关于Heron公式的主要内容,如果未能解决你的问题,请参考以下文章