The project will be submitted electronically through WebCT. Zip up your entire project folder for submission. (Right click on the project folder, follow the Send To link and select Compressed (zipped) Folder.) Once the compression process is done, you will have a zipped file with the same name as your project folder and an extension of .zip. This zipped file will be uploaded to the WebCT system during project submission. The project folder should include the following files:
You have been asked to write a program to classify triangles as obtuse, right, acute, or invalid. A triangle is obtuse if one of its angles is an obtuse angle, an angle greater than 90 degrees. A triangle is right if one of its angles is an right angle, an angle equal to 90 degrees. A triangle is acute if all of its angles are acute angles, each angle is less than 90 degrees.
In addition, a Triangle object can be constructed with side lengths that cannot form a triangle. The side of a triangle cannot be zero or negative. Any side of a triangle cannot be larger or equal to the sum of the other two sides. If the side lengths cannot form a triangle, the Triangle object is invalid.
If a, b and c are the lengths of the sides, then the following rules can be used to determine if the triangle is valid.
If the triangle is valid, then the following rules can be used to classify the triangle as obtuse, right or acute.If a is greater than or equal to b+c, then the triangle is invalid. Note that this rule applies if a is the longest side, and either b or c is zero or negative.
If b is greater than or equal to a+c, then the triangle is invalid.
If c is greater than or equal to a+b, then the triangle is invalid.
Otherwise, the triangle is valid.
If a*a is greater than b*b + c*c, then the triangle is obtuse.
If b*b is greater than a*a + c*c, then the triangle is obtuse.
If c*c is greater than a*a + b*b, then the triangle is obtuse.
If a*a is equal to b*b + c*c, then the triangle is right.
If b*b is equal to a*a + c*c, then the triangle is right.
If c*c is equal to a*a + b*b, then the triangle is right.
Otherwise, the triangle is acute.
Instance fields:
The instance fields are the same as for Project 1.
Constructors:
The constructor is the same as for Project 1.
Methods:
Two methods will be added, and the behavior of some methods will be changed.
The following methods should be added.
/* isValid returns true if the side lengths form a valid triangle */
public boolean isValid( )/* getClassification returns the classification of the triangle */
/* The output should be "obtuse", "right", "acute" or "invalid" */
public String getClassification( )
The following methods should be changed.
/* If the triangle is valid, getArea returns the area */
/* Otherwise, getArea returns zero */
public double getArea( )/* If the triangle is valid, getBase returns the base */
/* Otherwise, getBase returns zero */
public double getBase( )/* If the triangle is valid, getHeight returns the height */
/* Otherwise, getHeight returns zero */
public double getHeight( )/* toString returns a string describing the triangle, */
/* including the lengths, area, base, height and classification. */
public String toString( )