wa2blah
10-28-2005, 02:50 PM
Here is my code for a triangle program:
/**
* This program will do different things with a triangle like calculate area, etc.
*
* @author Murray McClafferty
* @version Oct. 27th, 2005
*/
public class Triangle
{
// instance variables
private double a; //One length
private double b; //Second length
private double c; //Third length
/**
* Constructor for objects of class Triangle
*/
public Triangle(double myA, double myB, double myC)
{
// initialise instance variables
a = myA;
b = myB;
c = myC;
}//constructor
/**
* Accessor for the a value
*
*
* @return the a value
*/
public double getA()
{
return a;
}//getA
/**
* Accessor for the b value
*
*
* @return the b value
*/
public double getB()
{
return b;
}//getB
/**
* Accessor for the c value
*
*
* @return the c value
*/
public double getC()
{
return c;
}//getC
/**
* Calculate the area of the triangle
*
* @return The area of the triangle
*/
public double area()
{
double s = .5 * (a + b + c); //s=semiperimeter
double area = Math.sqrt (s*(s-a)*(s-b)*(s-c));
return area;
}//area
/**
* Calculate perimeter of the Triangle
*
* @return The perimeter of the triangle
*/
public double perimeter()
{
double perimeter = a + b + c;
return perimeter;
}//perimeter
/**
* Calculate the angle of the three sides
*
* @return The angle of the three sides
*/
public double angle()
{
return angle;
}
}
Can someone explain to me how and what libraries I would use to calculate the angle in each corner of the triangle?
/**
* This program will do different things with a triangle like calculate area, etc.
*
* @author Murray McClafferty
* @version Oct. 27th, 2005
*/
public class Triangle
{
// instance variables
private double a; //One length
private double b; //Second length
private double c; //Third length
/**
* Constructor for objects of class Triangle
*/
public Triangle(double myA, double myB, double myC)
{
// initialise instance variables
a = myA;
b = myB;
c = myC;
}//constructor
/**
* Accessor for the a value
*
*
* @return the a value
*/
public double getA()
{
return a;
}//getA
/**
* Accessor for the b value
*
*
* @return the b value
*/
public double getB()
{
return b;
}//getB
/**
* Accessor for the c value
*
*
* @return the c value
*/
public double getC()
{
return c;
}//getC
/**
* Calculate the area of the triangle
*
* @return The area of the triangle
*/
public double area()
{
double s = .5 * (a + b + c); //s=semiperimeter
double area = Math.sqrt (s*(s-a)*(s-b)*(s-c));
return area;
}//area
/**
* Calculate perimeter of the Triangle
*
* @return The perimeter of the triangle
*/
public double perimeter()
{
double perimeter = a + b + c;
return perimeter;
}//perimeter
/**
* Calculate the angle of the three sides
*
* @return The angle of the three sides
*/
public double angle()
{
return angle;
}
}
Can someone explain to me how and what libraries I would use to calculate the angle in each corner of the triangle?