wangheng 4 years ago
parent 278a4a89b2
commit 1a78adbcfa

@ -0,0 +1,23 @@
public class d {
public static double angle(double a, String b) {
double c = Math.toRadians(a);
if (a % 180 == 0 && b.equals("sin")) {
return 0;
}
if (a % 90 == 0 && a % 180 != 0 && b.equals("cos")) {
return 0;
}
switch (b) {
case "cos":
return Math.cos(c);
case "sin":
return Math.sin(c);
case "tan":
return Math.tan(c);
case "cot":
return 1 / Math.tan(c);
}
return -1;
}
}
Loading…
Cancel
Save