In this program, you'll look at a function that "returns a value". When you call on the function to do a task, it will give you back a result.
A triangle with sides 3,3,3 has an area of 2.0 A triangle with sides 3,4,5 has an area of 6.0 A triangle with sides 7,8,9 has an area of 26.832815729997478 A triangle with sides 5,12,13 has an area of 30.0 A triangle with sides 10,9,11 has an area of 42.42640687119285 A triangle with sides 8,15,17 has an area of 60.0
Assignments turned in without these things will receive no credit.
triangleArea()
function?
(Put the answers to both questions in a comment in HeronsFormula.java.)
(a+b+c)
is an odd
number, dividing by 2
throws away the .5
. Fix both files
so that instead of (a+b+c) / 2
you have (a+b+c) / 2.0
everywhere
it occurs. Was it easier to fix the file that used a function, or the one that didn't
use a function? Answer in a comment.
A triangle with sides 3,3,3 has an area of 3.897114317029974 A triangle with sides 3,4,5 has an area of 6.0 A triangle with sides 7,8,9 has an area of 26.832815729997478 A triangle with sides 5,12,13 has an area of 30.0 A triangle with sides 10,9,11 has an area of 42.42640687119285 A triangle with sides 8,15,17 has an area of 60.0 A triangle with sides 9,9,9 has an area of 35.074028853269766
©2013 Graham Mitchell
This assignment is licensed under a
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License.