From 6bc3e9dba0030b4ed661a30b793c1d5f10fcf668 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=91=A3=E5=BA=86=E5=BC=BA?= Date: Wed, 10 May 2023 21:18:38 +0800 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 --- .../20230510\345\274\202\345\270\270.md" | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 "17 \350\221\243\345\272\206\345\274\272/20230510\345\274\202\345\270\270.md" diff --git "a/17 \350\221\243\345\272\206\345\274\272/20230510\345\274\202\345\270\270.md" "b/17 \350\221\243\345\272\206\345\274\272/20230510\345\274\202\345\270\270.md" new file mode 100644 index 0000000..87b07fd --- /dev/null +++ "b/17 \350\221\243\345\272\206\345\274\272/20230510\345\274\202\345\270\270.md" @@ -0,0 +1,24 @@ +```java +import java.util.Scanner; + +public class Dqq { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + while (true) { + System.out.println("请输入金额:"); + try { + double money = sc.nextDouble(); + if (money>=0){ + System.out.println("你输入的金额是:"+money); + break; + }else{ + System.out.println("金额不能负数:"); + } + } catch (Exception e) { + System.out.println("你输入的内容有误"); + sc.next(); + } + } + } +} +``` -- Gitee