commit 8340f0ca0cc42fff9fecaae9576cc87d67892098 Author: limengyan <1366329494@qq.com> Date: Fri Aug 7 21:59:38 2020 +0800 cp.java diff --git a/computer.java b/computer.java new file mode 100644 index 0000000..9146f6b --- /dev/null +++ b/computer.java @@ -0,0 +1,31 @@ +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; + } + +} + diff --git a/cp.java b/cp.java new file mode 100644 index 0000000..9146f6b --- /dev/null +++ b/cp.java @@ -0,0 +1,31 @@ +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; + } + +} +