41 lines
872 B
Java
41 lines
872 B
Java
package stringCheck;
|
|
|
|
import java.util.Scanner;
|
|
|
|
public class StringCheck {
|
|
public static void main(String[] args) {
|
|
String[] comment = new String[4];
|
|
comment[0] = "いまなにしてる?";
|
|
comment[1] = "何も入力されていません";
|
|
comment[2] = "投稿文が長すぎます";
|
|
comment[3] = "\"↓↓↓↓↓↓ 投稿されました ↓↓↓↓↓↓\"";
|
|
|
|
|
|
|
|
while (true) {
|
|
System.out.println(comment[0]);
|
|
Scanner scanner = new Scanner(System.in);
|
|
String text = scanner.nextLine();
|
|
String str = text.strip();
|
|
|
|
|
|
|
|
if(str.length() == 0) {
|
|
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;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|