孙鸿涛 4 years ago
commit 8542614d8d

@ -0,0 +1,62 @@
package collaboration;
import java.util.Scanner;
import java.math.*;
public class Calculator {
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
double result=1.0;
String Command=sc.nextLine();
String parameters=sc.nextLine();
if(Command.equals("0"))
result=Calculator.Log(parameters);
// else if(Command.equals("1"))
// result=Calculator.ex(parameters);
// else if(Command.equals("2"))
// result=Calculator.jjcc(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(" ");
float a=Float.parseFloat(parameters[0]);
float b=Float.parseFloat(parameters[1]);
double result=Math.log(b)/Math.log(a);
return result;
}
public static double sin(String s)
{
double x=Double.parseDouble(s);
return Math.sin(Math.toRadians(x));//Math.toRadians()½«½Ç¶Èת»»Îª»¡¶È
}
public static double cos(String s)
{
double x=Double.parseDouble(s);
return Math.cos(Math.toRadians(x));
}
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()
// {
//
// }
}

@ -0,0 +1,19 @@
package collaborative;
/**
* @author suyi
* @version 1.0
* @date 2020/8/6 18:00
*/
public class ExFunction {
public double x;
public ExFunction(double x) {
this.x = x;
}
public double index() {
return Math.exp(x);
}
}

@ -0,0 +1,32 @@
package collaboration;
import java.math.*;
public class TrigonometricFunction {
static double x;
public TrigonometricFunction (double x)
{
this.x=x;
}
public static double sin( ) //计算角度x对应的正弦值
{
return Math.sin(Math.toRadians(x));//Math.toRadians()将角度转换为弧度
}
public static double cos()//计算角度x对应的余弦值
{
return Math.cos(Math.toRadians(x));
}
public static double tan()//计算角度x对应的正切值
{
return Math.tan(Math.toRadians(x));
}
// public static void main (String[] args)
// {
// double x=90;
// TrigonometricFunction t=new TrigonometricFunction(x);
// System.out.println(t.sin());
// }
}
Loading…
Cancel
Save