You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
1.0 KiB

4 years ago
package computer;
import java.util.Scanner;
public class compute {
public static void main(String[] args) {
// TODO Auto-generated method stub
Double op1;
Double op2;
String op;
Scanner sc = new Scanner(System.in);
System.out.println("请输入第一个操作数(回车结束)");
op1=sc.nextDouble();
System.out.println("请输入运算符(回车结束)");
op=sc.next();
System.out.println("请输入第二个操作数(回车结束)");
op2=sc.nextDouble();
System.out.print("结果是:");
switch(op) {
case "+":System.out.println(coputer1(op1,op2));break;
case "-":System.out.println(coputer1(op1,op2));break;
case "*":System.out.println(coputer1(op1,op2));break;
case "/":System.out.println(coputer1(op1,op2));break;
case "^":System.out.println(function(op1,op2));break;
case "log":System.out.println(logax(op1,op2));break;
case "e^" :System.out.println(calcalate(op2));break;
}
}