Hello all you Java programmers out there. I have a tiny problem. The code is not allowing me to use the cos(double x) and acos(double x) methods even though I imported the math class. So....Whats wrong with my code???
/*
* Andre Taylor
* 10/26/2010
* This program is a prototype that is designed to use the law of cosines to solve oblique triangles
* The user inputs the given values and the program computes and displays
* solved triangle
*/
package obliquetrianglescosine;
import java.lang.Math; //*Imported to use cosine and arccosin methods
//Its not working for some reason. it Says unused port even though I
//call for the cos and arccos method
import java.util.Scanner;
/**
*
* @author owner
*/
public class cosineLaw {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
double a; //Declare variables for values given
double b;
double c;
double A;
double B;
double C;
System.out.println("So what info was given to you? If nothing is input put 0 where value is."); //User inputs info given if nothing given user inputs 0
System.out.print("a:");
Scanner input = new Scanner (System.in);
a= input.nextDouble();
System.out.print("b:");
b= input.nextDouble();
System.out.print("c:");
c= input.nextDouble();
System.out.print("A:");
A= input.nextDouble();
System.out.print("B:");
B= input.nextDouble();
System.out.print("C:");
C= input.nextDouble();
computeLastSide( a, b, C, c);
computeSecondAngle( a, b, c,A);
computeLastAngle( A, B, C);
System.out.println("Side c= "+c);
System.out.println("Angle A= "+A);
System.out.println("Angle B= "+B);
}
public static double computeLastSide(double a,double b,double C, double c) //computes the last side of triangle
{
c =(a*a+b*b)-2*a*b*cos(C);
return c;
}
public static double computeSecondAngle(double a, double b, double c, double A) //computes second angle
{
A = acos(((b*b+c*c)-a*a)/2*b*c);
return A;
}
public static double computeLastAngle(double A, double B, double C) //computes last angle
{
B= 180-A-C;
return B;
}
}