diff --git a/代码/duishu.java b/代码/duishu.java new file mode 100644 index 0000000..ac29411 --- /dev/null +++ b/代码/duishu.java @@ -0,0 +1,9 @@ +package open; + +public class duishu { + + public double duishu(double a,double b) { + return Math.log(a)/Math.log(a); + } + +} diff --git a/代码/main.java b/代码/main.java new file mode 100644 index 0000000..7a476e8 --- /dev/null +++ b/代码/main.java @@ -0,0 +1,58 @@ +package open; +import java.util.Scanner; +public class main { + + public main() { + + } + + public static void main(String[] args) { + double a,c; String b; + Scanner sc = new Scanner(System.in); + a=sc.nextDouble(); + b=sc.next(); + if(b.equals("sin")) { + sanjiao d=new sanjiao(); + System.out.println(d.sanjiao("sin", a)); + } + else if(b.equals("cos")) { + sanjiao d=new sanjiao(); + System.out.println(d.sanjiao("cos", a)); + } + else if(b.equals("tan")) { + sanjiao d=new sanjiao(); + System.out.println(d.sanjiao("tan", a)); + } + else if(b.equals("^")) { + zhishu d=new zhishu(); + System.out.println(d.zhishu(a)); + } + else if(b.equals("log")) { + duishu d=new duishu(); + c=sc.nextDouble(); + System.out.println(d.duishu(a, c)); + } + else if(b.equals("+")) { + sizeyunsuan d=new sizeyunsuan(); + c=sc.nextDouble(); + System.out.println(d.add(a, c)); + } + else if(b.equals("-")) { + sizeyunsuan d=new sizeyunsuan(); + c=sc.nextDouble(); + System.out.println(d.subtract(a, c)); + } + else if(b.equals("*")) { + sizeyunsuan d=new sizeyunsuan(); + c=sc.nextDouble(); + System.out.println(d.multiply(a, c)); + } + else if(b.equals("/")) { + sizeyunsuan d=new sizeyunsuan(); + c=sc.nextDouble(); + System.out.println(d.divide(a, c)); + } + else System.out.println(""); + } + +} diff --git a/代码/sanjiao.java b/代码/sanjiao.java new file mode 100644 index 0000000..dc8ce40 --- /dev/null +++ b/代码/sanjiao.java @@ -0,0 +1,16 @@ +package open; + +public class sanjiao { + +public double sanjiao(String a,double b) { + double c=Math.toRadians(b); + if(a=="sin") + return Math.sin(c); + else if(a=="cos") + return Math.cos(c); + else if(a=="tan") + return Math.tan(c); + return 0; +} + +} diff --git a/代码/sizeyunsuan.java b/代码/sizeyunsuan.java new file mode 100644 index 0000000..97f21c8 --- /dev/null +++ b/代码/sizeyunsuan.java @@ -0,0 +1,32 @@ +package open; + +public class sizeyunsuan { + + public double add(double add1, double add2) { + //ӷ + double result; + result = add1 + add2; + return result; + } + + public double subtract(double sub1, double sub2) { + // + double result; + result = sub1 - sub2; + return result; + } + + public double multiply(double mul1, double mul2) { + //˷ + double result; + result = mul1 * mul2; + return result; + } + + public double divide(double div1, double div2) { + // + double result; + result = div1 / div2; + return result; + } +} diff --git a/代码/zhishu.java b/代码/zhishu.java new file mode 100644 index 0000000..9f6eab6 --- /dev/null +++ b/代码/zhishu.java @@ -0,0 +1,11 @@ +package open; + +public class zhishu { + + public double zhishu(double a) { + return Math.pow(Math.E,a); + + } + + +}