Results 1 to 1 of 1

# Thread: Need Help - Almost There!

- 11-08-2010, 12:47 AM #1Member
- Join Date
- Nov 2010
- Posts
- 87

- Rep Power
- 0

## Need Help - Almost There!

Hey all, i'm putting this on a new post because I think the other one looks so big, no1 is looking at it... My objective is to make a table along the lines of this...

*******************************************

* a * b * c * area *

*******************************************

* 1 * 1 * 1 * … *

* 1 * 2 * 2 * … *

* 1 * 3 * 3 * … *

* 1 * 4 * 4 * … *

…

* 6 * 7 * 7 * … *

***************************************

Q: Assuming a,b,c are integers and the circumference a+b+c is no larger than 20, create a program TriangleArea.java to enumerate all the combinations of edge lengths, and calculate the corresponding area of the triangle. Be aware that not all the combinations correspond to a valid triangle (the side lengths of a valid triangle must satisfy the triangle inequality). You should print "equivalent" triangles only once, e.g. a triangle with edge lengths (2, 3, 4) is "equivalent" to a triangle with edge lengths (4, 2, 3). The output from the program should be laid out as follows:

I think i have done everything I need now logic wise etc but I am unsure of how to enter code at the end that will actually produce something like the table above. It has been an epic day and I have now worked on this for 12 hours so any help getting me to the finish line would mean allot to me. Thanks xD

Atia

Java Code:public class TriangleArea { public static void main( String[] args ) {} int a; int b; int c; boolean isTriangle;{ if ( (a+ b <= c) & (b + c <= a) & (a + c <= b) ) {isTriangle = false;} else {isTriangle = true;} { for (a= 1; a <= 20; a++) { for (b= a; b <= 20; b++) { for ( c= b; c <= 20; c++){ if ((a < b+c) && (b < a+c) && (c < a+b)) break; else continue;}}}} } public static double area(double a, double b, double c){ double s = Math.sqrt( (a + b + c) / 2 ) ; double area = s * (s - a) * ( s - b ) * (s - c ); return area; System.out.println(); } }

## Bookmarks