From 762e4c7dd21c61df20bf9491ab3eb656d9ae83a5 Mon Sep 17 00:00:00 2001 From: the1dog Date: Thu, 6 Aug 2020 19:08:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cal4.java | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 cal4.java diff --git a/cal4.java b/cal4.java deleted file mode 100644 index dd7d00e..0000000 --- a/cal4.java +++ /dev/null @@ -1,31 +0,0 @@ -package calculator; - -import java.util.Scanner; - -public class cal4 { - public cal4() { - Scanner inScanner=new Scanner(System.in); - System.out.print("请输入第一位运算数:"); - double a=inScanner.nextInt(); - System.out.print("请输入第二位运算数:"); - double b=inScanner.nextInt(); - System.out.print("请输入将要运算的运算符:"); - String op=inScanner.next(); - char ch=op.charAt(0); - double sum=cala(a, b, ch); - System.out.println("结果为:"+sum); - } - - public static double cala(double x,double y,char op) { - switch (op) { - case '+': return x+y; - case '-': return x-y; - case '*': return x*y; - case '/': - if(y==0) return 0; - else return x/y; - default: - return x; - } - } -} \ No newline at end of file