From 8aa6c22f26ecb2e63fd1ecdd4c9c99f96eb14ca3 Mon Sep 17 00:00:00 2001 From: limengyan <1366329494@qq.com> Date: Fri, 7 Aug 2020 22:21:17 +0800 Subject: [PATCH] cc.java --- cc.java | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 cc.java diff --git a/cc.java b/cc.java new file mode 100644 index 0000000..9146f6b --- /dev/null +++ b/cc.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; + } + +} +