|
|
|
@ -1,8 +1,8 @@
|
|
|
|
|
|
|
|
|
|
package cn.edu.gxu;
|
|
|
|
|
package 三角函数运算;
|
|
|
|
|
|
|
|
|
|
import java.util.Scanner;
|
|
|
|
|
|
|
|
|
|
import java.math.*;
|
|
|
|
|
|
|
|
|
|
public class Calculator {
|
|
|
|
|
public static void main(String[] args)
|
|
|
|
@ -17,30 +17,46 @@ public class Calculator {
|
|
|
|
|
// result=Calculator.ex(parameters);
|
|
|
|
|
// else if(Command.equals("2"))
|
|
|
|
|
// result=Calculator.jjcc(parameters);
|
|
|
|
|
// else
|
|
|
|
|
// result=Calculator.sin(parameters);
|
|
|
|
|
else if(Command.equals("6"))
|
|
|
|
|
result=Calculator.sin(parameters);
|
|
|
|
|
else if(Command.equals("7"))
|
|
|
|
|
result=Calculator.cos(parameters);
|
|
|
|
|
else if(Command.equals("8"))
|
|
|
|
|
result=Calculator.tan(parameters);
|
|
|
|
|
System.out.println(result);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
public static double Log(String s)
|
|
|
|
|
{
|
|
|
|
|
String[] parameters=new String[2];
|
|
|
|
|
parameters=s.split(" ");//用空格切分传过来的两个数字
|
|
|
|
|
parameters=s.split(" ");
|
|
|
|
|
float a=Float.parseFloat(parameters[0]);
|
|
|
|
|
float b=Float.parseFloat(parameters[1]);
|
|
|
|
|
double result=Math.log(b)/Math.log(a); //log 都是用e为底,还要用个换底公式OvO
|
|
|
|
|
double result=Math.log(b)/Math.log(a);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
public static double sin()
|
|
|
|
|
public static double sin(String s)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
double x=Double.parseDouble(s);
|
|
|
|
|
return Math.sin(Math.toRadians(x));//Math.toRadians()将角度转换为弧度
|
|
|
|
|
}
|
|
|
|
|
public static double jjcc()//加减乘除哈哈
|
|
|
|
|
public static double cos(String s)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
double x=Double.parseDouble(s);
|
|
|
|
|
return Math.cos(Math.toRadians(x));
|
|
|
|
|
}
|
|
|
|
|
public static double ex()//e的幂
|
|
|
|
|
public static double tan(String s)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
double x=Double.parseDouble(s);
|
|
|
|
|
return Math.tan(Math.toRadians(x));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// public static double jjcc()
|
|
|
|
|
// {
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
// public static double ex()
|
|
|
|
|
// {
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|