From 1a78adbcfa24675f7c346ca18f031a3b2cfe04c3 Mon Sep 17 00:00:00 2001 From: wangheng <707428731@qq.com> Date: Thu, 6 Aug 2020 18:22:45 +0800 Subject: [PATCH] d.java --- d.java | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 d.java diff --git a/d.java b/d.java new file mode 100644 index 0000000..957cbf2 --- /dev/null +++ b/d.java @@ -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; + } +}