``````/**
* 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()
{
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! :(

that's because you cannot use those keywords inside methods.

hi:
your writing which method of arccoseA maybe is wrong!

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))
angleB = Math.acos((2 * b - 2 * a - 2 * c) / (-2 * a * b))
angleA = Math.acos((2 * a - 2 * c - 2 * b) / (-2 * a * b))
}
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;
}
}

commented: ur fucking retarded -2

Wow, thanks you guys are great! :)

Heh, I needed a * in between the (-2 * a * b)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.