|
|
@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
package cn.edu.gxu;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.Scanner;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
// result=Calculator.sin(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); //log 都是用e为底,还要用个换底公式OvO
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public static double sin()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public static double jjcc()//加减乘除哈哈
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public static double ex()//e的幂
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|