From 2577de18bc5723812acf4986adda21c6f8900db8 Mon Sep 17 00:00:00 2001 From: m_ozawa <26-m-ozawa-swnet@it-college.co.jp> Date: Wed, 9 Sep 2026 13:43:27 +0900 Subject: [PATCH] =?UTF-8?q?2=E6=97=A5=E7=9B=AE=E3=80=80=E6=AE=B5=E9=9A=8E?= =?UTF-8?q?=EF=BC=93=E3=80=80=E5=B0=8F=E6=BE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- StringCheck/src/stringCheck/StringCheck.java | 53 +++++++++++--------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/StringCheck/src/stringCheck/StringCheck.java b/StringCheck/src/stringCheck/StringCheck.java index 4528ac8..4af15c0 100644 --- a/StringCheck/src/stringCheck/StringCheck.java +++ b/StringCheck/src/stringCheck/StringCheck.java @@ -9,32 +9,37 @@ public class StringCheck { comment[1] = "何も入力されていません"; comment[2] = "投稿文が長すぎます"; comment[3] = "\"↓↓↓↓↓↓ 投稿されました ↓↓↓↓↓↓\""; - - for(String testComm : comment) { - System.out.println(testComm); - } - - - while(true) { + +// for (String testComm : comment) { +// System.out.println(testComm); +// } + + while (true) { + System.out.println(comment[0]); + Scanner scanner = new Scanner(System.in); + String text = scanner.nextLine(); + String str = text.strip(); - System.out.println(comment[0]); - Scanner scanner = new Scanner(System.in); - String text = scanner.next(); - String str = text.strip(); - System.out.println("\n" + comment[3]); - } - -// System.out.println(str); -// -// System.out.println(str.length() == 0); -// System.out.println(str.length() > 140); -// -// System.out.println(140-str.length()); - - } +// System.out.println(str.length() == 0); +// System.out.println(str.length() > 140); +// +// System.out.println(140 - str.length()); + + if(str.length() < 1) { + System.out.println("何も入力されていません"); + continue; + }else if(str.length() > 140){ + System.out.println("投稿文が長すぎます"); + continue; + }else { + System.out.println("\n" + comment[3]); + System.out.println(str); + break; + } + } + + } } - -