Swift

Solution - Heron's Formula

Our solution to the mini-project

Our Solution

Here is our solution. Your solution does not have to look like ours. If it works and is concise, then you’ve done it right!

func TrigArea(a: Double, b: Double, c: Double) -> Double {
    let s: Double = (a+b+c)/2
    let x: Double = s*(s-a)*(s-b)*(s-c)
    return x.squareRoot()
}
print("Area of Triangle 1: \(TrigArea(a: 10, b: 12, c: 15))")
print("Area of Triangle 2: \(TrigArea(a: 12, b: 14, c: 7))")

Feel free to contact us if you have any questions.

chevron_up