From f05e9458d542b63eedc1e629ee44aa76f62ee544 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E5=A2=9E=E5=85=B4?= <12071383+fang-zengxing@user.noreply.gitee.com> Date: Wed, 10 May 2023 10:32:00 +0000 Subject: [PATCH] =?UTF-8?q?=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 方增兴 <12071383+fang-zengxing@user.noreply.gitee.com> --- .../\345\274\202\345\270\270.md" | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 "\346\226\271\345\242\236\345\205\264/\345\274\202\345\270\270.md" diff --git "a/\346\226\271\345\242\236\345\205\264/\345\274\202\345\270\270.md" "b/\346\226\271\345\242\236\345\205\264/\345\274\202\345\270\270.md" new file mode 100644 index 0000000..c5e3f71 --- /dev/null +++ "b/\346\226\271\345\242\236\345\205\264/\345\274\202\345\270\270.md" @@ -0,0 +1,36 @@ +```java +import java.util.Scanner; + +public class Two { + double getnum() { + System.out.println("请输入第一个数字:"); + Scanner scanner = new Scanner(System.in); + double num1 = scanner.nextDouble(); + System.out.println("请输入第二个数字:"); + double num2 = scanner.nextDouble(); + return num1 + num2; + } + + void re() { + double sum = new Two().getnum(); + System.out.println("两数之和为:" + sum); + } + + public static void main(String[] args) { + while (true) { + try { + new Two().re(); + } catch (Exception e) { + System.out.println("请重新输入!"); + System.out.println("错误为"+e); + try { + } finally { + new Two().re(); + } + } + + } + } +} +``` + -- Gitee