From b94311b537e3fb2776d29c2b87ed076d75d4c7af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=96=87=E9=94=8B?= <2069827762@qq.com> Date: Wed, 10 May 2023 22:10:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=82=E5=B8=B8=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20230310java\344\275\234\344\270\232.md" | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 "07 \345\210\230\346\226\207\351\224\213/20230310java\344\275\234\344\270\232.md" diff --git "a/07 \345\210\230\346\226\207\351\224\213/20230310java\344\275\234\344\270\232.md" "b/07 \345\210\230\346\226\207\351\224\213/20230310java\344\275\234\344\270\232.md" new file mode 100644 index 0000000..20ac9b0 --- /dev/null +++ "b/07 \345\210\230\346\226\207\351\224\213/20230310java\344\275\234\344\270\232.md" @@ -0,0 +1,28 @@ +```java +# 作业 + +~~~ java +import java.util.InputMismatchException; +import java.util.Scanner; + +public class Test { + public static void main(String[] args){ + while (true){ + Scanner sc = new Scanner(System.in); + try { + System.out.println("请输入第一个整数:"); + int a = sc.nextInt(); + System.out.println("请输入第二个整数:"); + int b = sc.nextInt(); + System.out.print("两个整数的和="); + System.out.println(a+b); + break; + } catch (Exception e) { + System.out.println("数字不能是整数以外的数字!"); + } + } + } +} + +~~~ +``` \ No newline at end of file -- Gitee