I am writing a program for my Java class that takes the length of two sides of a right triangle, and calculates the hypotenuse, as well as the sine, cosine, and tangent of each non-right angle of the right triangle. The calculations for the hypotenuse, sine, cosine, and tangent should be placed in separate methods.
I keep getting two errors when I try to declare my methods, 'class' expected and ')' expected. I cannot figure out what I am doing wrong, any help would be appreciated.
import java.util.*; import static java.lang.Math.*; public class RightTriangle { public static void main(String[] args) { double a, b, c; System.out.println("Please enter first length" + " of side of the triangle", a); a = console.nextDouble(); System.out.println("The opposite side of the" + "triangle is ", a); System.out.println("Please enter second length" + " of side of the triangle", b); b = console.nextDouble(); System.out.println("The adjacent side of the" + "trianlge is ", b); c =((a*a) + (b*b)); hypotenuse = c*c; System.out.println("The hypotenuse of the triangle" + "is ", hypotenuse); sine(double a, double c); cosine(double b, double c); tangent(double b, double c); } public static double getSine(double a, double c) { double opp; double hyp; opp = a.getNum(); hyp = c.getNum(); sine = opp/hyp; System.out.println("The sine of the triangle" + "is ", sine); } public static double getCosine(double b, double c) { double adj; double hyp; adj = b.getNum(); hyp = c.getNum(); cosine = adj/hyp; System.out.println("The cosine of the triangle" + "is ", cosine); } public static double getTangent(double a, double b) { double opp; double adj; opp = a.getNum(); adj = b.getNum(); tangent = a/b; System.out.println("The tangent of the triangle" + "is ", tangent); } }