/**
 * Finds the angles of A, B, and C when given the sides. 
 * Caleb Hess
 * 4/27/07
 */
public class Triangle
{
    /** 
     *@param a the length of a for the triangle 
     *@param b the length of b for the triangle
     *@param c the length of c for the triangle
     */
    public Triangle(double a, double b, double c)
    {
        this.a = a;
        this.b = b;
        this.c = c;
        angleA = 0;
        angleB = 0;
        angleC = 0;
        area = 0;
        perimeter = 0;
    }
    
    public double calculateAngles()
    {
        final double RADIANS_TO_DEGREES = 180/Math.PI;
        angleC = Math.acos((c * c - b * b - a * a)/(-2ab)) * RADIANS_TO_DEGREES;
        angleB = Math.acos((b * b - a * a - c * c)/(-2ab)) * RADIANS_TO_DEGREES;
        angleA = Math.acos((a * a - c * c - b * b)/(-2ab)) * RADIANS_TO_DEGREES;
    }
    
    public double calculateArea()
    {
        area = Math.sqrt((a + b + c)(a + b - c)(b + c - a)(c + a -b)) / 4;
    }
    
    public double calculatePerimeter()
    {
        perimeter = (a + b + c);
    }

I get the error in my angleC = Math.acos line... anyone see what i did wrong?

I added public static in front of my constant and it says illegal start of expression.

Sorry for double posting but I lost the revise button somehow! :(

hi:
you can analyse this coding program
package com.applet;
public class Triangle {
/**
* @param a
* the length of a for the triangle
* @param b
* the length of b for the triangle
* @param c
* the length of c for the triangle
*/
private double a, b, c;
private double angleA, angleB, angleC, area, perimeter;
public Triangle(double a, double b, double c) {
this.a = a;
this.b = b;
this.c = c;
angleA = 0;
angleB = 0;
angleC = 0;
area = 0;
perimeter = 0;
}
public void calculateAngles() {
final double RADIANS_TO_DEGREES = 180 / Math.PI;
angleC = Math.acos((2 * c - 2 * b - 2 * a) / (-2 * a * b))
* RADIANS_TO_DEGREES;
angleB = Math.acos((2 * b - 2 * a - 2 * c) / (-2 * a * b))
* RADIANS_TO_DEGREES;
angleA = Math.acos((2 * a - 2 * c - 2 * b) / (-2 * a * b))
* RADIANS_TO_DEGREES;
}
public double calculateArea() {
double halfperimeter = calculatePerimeter() / 2;
return area = Math.sqrt(halfperimeter * (halfperimeter - a)
* (halfperimeter - b) * (halfperimeter - c));
}
public double calculatePerimeter() {
return perimeter = (a + b + c);
}
public double getAngleA() {
return angleA;
}
public void setAngleA(double angleA) {
this.angleA = angleA;
}
public double getAngleB() {
return angleB;
}
public void setAngleB(double angleB) {
this.angleB = angleB;
}
public double getAngleC() {
return angleC;
}
public void setAngleC(double angleC) {
this.angleC = angleC;
}
public double getArea() {
return area;
}
public void setArea(double area) {
this.area = area;
}
public double getPerimeter() {
return perimeter;
}
public void setPerimeter(double perimeter) {
this.perimeter = perimeter;
}
}

Comments
ur fucking retarded
This question has already been answered. Start a new discussion instead.