What does this question mean?
So this is my assignment and I am having trouble trying to understand this question in part a, basically the part b is calculating area of a triangle which is tied up with the part a, the main issue is that I have declared the double variable for a,b and c but the logic of settng the sides and then making sure that the sum of any two sides should be greater than the third one. How to do this?
Quote:
(a) Write a Java class InvalidValueException. Objects of this class, when created, will
show a simple message informing you of the nature of the exception thrown.
(b) Given three straight lines a, b & c. They will be able to form a triangle provided that sum
of any two lines is always greater than the third line (i.e. a + b > c and b + c > a and a + c
> b).
Write a Java class Triangle with the following:
„h Attributes: length of the three sides of the triangle
„h Behaviour:
- Constructor that sets the length of the three sides to the values passed in. The
constructor should throw an InvalidValueException object when the values
are not able to form a triangle.
- findArea() method to calculate the area of the Triangle object using the
formula
area = s * (s ƒ{ a) * (s ƒ{ b) * (s ƒ{ c) where s =
2
a ƒy b ƒy c
Re: What does this question mean?
Quote:
making sure that the sum of any two sides should be greater than the third one.
I guess you'd add together two of the sides and compare the results to the third side.
Do that for each possible pair of sides.
Re: What does this question mean?
Quote:
Originally Posted by
Norm
I guess you'd add together two of the sides and compare the results to the third side.
Do that for each possible pair of sides.
wat about the part a? (texting habit hehe)
Re: What does this question mean?
Is there something wrong with your keyboard? Your last post is messed up.