Day2 stept 4

This commit is contained in:
2026-09-09 15:19:17 +09:00
parent e8bdd3f18a
commit d16b47bc60

View File

@@ -12,42 +12,37 @@ public class StringCheck {
//int maxLength = 140;
// 段階1: 無限ループ化
while (true) {
System.out.println(messages[0]);
str = scan.nextLine();
//str = scan.nextLine().trim();
str = str.replaceAll("[\\s ]", "");
//String str1 = str.replaceAll("[  ]", "");
while (true) {
System.out.println(messages[0]);
str = scan.nextLine();
//str = scan.nextLine().trim();
str = str.replaceAll("[\\s ]", "");
//String str1 = str.replaceAll("[  ]", "");
//System.out.println("あなたの入力は: [" + str + "]");
//2段階のif
boolean isEmpty = str.isEmpty();
boolean isTooLong = str.length() > 140;
if(isEmpty) {
System.out.println(messages[1]);
continue;
}
//System.out.println("あなたの入力は: [" + str + "]");
//2段階のif
boolean isEmpty = str.isEmpty();
boolean isTooLong = str.length() > 140;
if (isEmpty) {
System.out.println(messages[1]);
continue;
}
//(Length check) 140 under
if (isTooLong) {
System.out.println(messages[2]);
continue;
}
break;
}
System.out.println();
System.out.println(messages[3]);
System.out.println(str);
scan.close();
if (isTooLong) {
System.out.println(messages[2]);
continue;
}
break;
}
System.out.println();
System.out.println(messages[3]);
System.out.println(str);
scan.close();
}
}
}