From 45f11601d6d28036f35aca3b27b4fe878a1d7498 Mon Sep 17 00:00:00 2001 From: YiBo <1322450307@qq.com> Date: Thu, 6 Aug 2020 20:28:32 +0800 Subject: [PATCH] c.java --- c.java | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 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; + } + } +}