package guangzhaowei; import java.util.Scanner; public class Triangle { public static void angle(){ Scanner sc= new Scanner(System.in); System.out.println("三角函数类型:"); String b=sc.next(); System.out.println("数值:"); double a=sc.nextDouble(); double c = Math.toRadians(a); if (a % 180 == 0 && b.equals("sin")) { System.out.println("运算结果是0"); } if (a % 90 == 0 && a % 180 != 0 && b.equals("cos")) { System.out.println("运算结果是0"); } switch (b) { case "cos": System.out.println("运算结果是"+Math.cos(c)); break; case "sin": System.out.println("运算结果是"+Math.sin(c)); break; case "tan": System.out.println("运算结果是"+Math.tan(c)); break; case "cot": System.out.println("运算结果是"+1 / Math.tan(c)); break; } } }