commit 45f11601d6d28036f35aca3b27b4fe878a1d7498 Author: YiBo <1322450307@qq.com> Date: Thu Aug 6 20:28:32 2020 +0800 c.java diff --git a/c.java b/c.java new file mode 100644 index 0000000..a901127 --- /dev/null +++ b/c.java @@ -0,0 +1,26 @@ +import java.util.Scanner; +public class CALC{ + public static void main(String args[]){ + double x; + double y; + String z; + Scanner sc=new Scanner(System.in) + System.out.println("输入第一个数:"); + x=sc.nextDouble(); + System.out.println("输入运算符:"); + z=sc.next(); + System.out.println("输入第二个数:"); + y=sc.nextDouble(); + System.out.print("结果是:"); + switch(z){ + case"+":System.out.println(x+y); + break; + case"-":System.out.println(x-y); + break; + case"*":System.out.println(x*y); + break; + case"/":System.out.println(x/y); + break; + } + } +}