|
|
|
@ -7,7 +7,7 @@ public class Calculator {
|
|
|
|
|
{
|
|
|
|
|
Scanner sc=new Scanner(System.in);
|
|
|
|
|
double result=1.0;
|
|
|
|
|
System.out.println("对数 0;sin 6;cos 7;tan 8;e的指数 1; ");
|
|
|
|
|
System.out.println("对数 0;sin 6;cos 7;tan 8;e的指数 1;加 2;减 3;乘 4;除 5 ");
|
|
|
|
|
String Command=sc.nextLine();
|
|
|
|
|
System.out.println("输入对应运算数值 两数以空格间隔");
|
|
|
|
|
String parameters=sc.nextLine();
|
|
|
|
@ -19,8 +19,43 @@ public class Calculator {
|
|
|
|
|
ExFunction e = new ExFunction(Double.parseDouble(parameters));
|
|
|
|
|
result=e.index();
|
|
|
|
|
}
|
|
|
|
|
// else if(Command.equals("2"))
|
|
|
|
|
// result=Calculator.jjcc(parameters);
|
|
|
|
|
else if(Command.equals("2"))
|
|
|
|
|
{
|
|
|
|
|
String[] s=new String[2];
|
|
|
|
|
s=parameters.split(" ");
|
|
|
|
|
double a=Double.parseDouble(s[0]);
|
|
|
|
|
double b=Double.parseDouble(s[1]);
|
|
|
|
|
jjcc e = new jjcc();
|
|
|
|
|
result = e.add(a,b);
|
|
|
|
|
}
|
|
|
|
|
else if(Command.equals("3"))
|
|
|
|
|
{
|
|
|
|
|
String[] s=new String[2];
|
|
|
|
|
s=parameters.split(" ");
|
|
|
|
|
double a=Double.parseDouble(s[0]);
|
|
|
|
|
double b=Double.parseDouble(s[1]);
|
|
|
|
|
jjcc e = new jjcc();
|
|
|
|
|
result = e.sub(a,b);
|
|
|
|
|
}
|
|
|
|
|
else if(Command.equals("4"))
|
|
|
|
|
{
|
|
|
|
|
String[] s=new String[2];
|
|
|
|
|
s=parameters.split(" ");
|
|
|
|
|
double a=Double.parseDouble(s[0]);
|
|
|
|
|
double b=Double.parseDouble(s[1]);
|
|
|
|
|
jjcc e = new jjcc();
|
|
|
|
|
result = e.mul(a,b);
|
|
|
|
|
}
|
|
|
|
|
else if(Command.equals("5"))
|
|
|
|
|
{
|
|
|
|
|
String[] s=new String[2];
|
|
|
|
|
s=parameters.split(" ");
|
|
|
|
|
double a=Double.parseDouble(s[0]);
|
|
|
|
|
double b=Double.parseDouble(s[1]);
|
|
|
|
|
jjcc e = new jjcc();
|
|
|
|
|
result = e.div(a,b);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if(Command.equals("6"))
|
|
|
|
|
result=Calculator.sin(parameters);
|
|
|
|
|
else if(Command.equals("7"))
|
|
|
|
@ -75,4 +110,28 @@ public class Calculator {
|
|
|
|
|
return Math.exp(x);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
class jjcc {
|
|
|
|
|
|
|
|
|
|
public double x;
|
|
|
|
|
|
|
|
|
|
public jjcc() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
public double add(double a,double b)
|
|
|
|
|
{
|
|
|
|
|
return a+b;
|
|
|
|
|
}
|
|
|
|
|
public static double sub(double a,double b)
|
|
|
|
|
{
|
|
|
|
|
return a-b;
|
|
|
|
|
}
|
|
|
|
|
public static double mul(double a,double b)
|
|
|
|
|
{
|
|
|
|
|
return a*b;
|
|
|
|
|
}
|
|
|
|
|
public static double div(double a,double b)
|
|
|
|
|
{
|
|
|
|
|
return (double)a/b;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|