I need to create a program that prompts for the lengths of a triangle and computes it. I have the equations figured out (bottom of code). What I am stuck on though is, well, getting it to work.
Any help here would be FAN-FREAKING-TASTIC!
PS.
I won't lie, this is a homework assignment. What you see below is what I have completed on my own so far. Just need a little help working out the bugs >.<
import java.util.*;
public class Triangle {
public static void main(String[] args) {
Scanner console = new Scanner(System.in);
System.out.print("Length A? ");
int a = console.nextInt();
System.out.print("Length B? ");
int b = console.nextInt();
System.out.print("Length C? ");
int c = console.nextInt();
}
public static computeAngleC(double a, double b, double c) {
int angle = Math.acos((a * a + b * b - c * c) / (2 * a * b));
// convert to degrees and return
return Math.toDegrees(angle);
}
public static double computeAngleB(double a, double b, double c) {
double angle = Math.acos((a * a + c * c - b * b) / (2 * a * c));
// convert to degrees and return
return Math.toDegrees(angle);
}
public static double computeAngleA(double a, double b, double c) {
double angle = Math.acos((b * b + c * c - a * a) / (2 * b * c));
// convert to degrees and return
return Math.toDegrees(angle);
}
}
/*computeAngle C = arcos(a2 + b2 - c2) / (2 ab);
computeAngle B = arcos(a2 + c2 - b2) / (2 ac);
computeAngle A = arcos(b2 + c2 - a2) / (2 bc);*/