3日目(内容は2日目)
This commit is contained in:
54
StringCheack_20261009福森.java
Normal file
54
StringCheack_20261009福森.java
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class StringCheack_20261009福森 {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// TODO 自動生成されたメソッド・スタブ
|
||||||
|
|
||||||
|
Scanner scanner = new Scanner(System.in);
|
||||||
|
|
||||||
|
while(true) {
|
||||||
|
//画面に「いまなにしてる?」を表示する
|
||||||
|
System.out.println("いまなにしてる?");
|
||||||
|
|
||||||
|
//標準入力
|
||||||
|
String str = scanner.nextLine();
|
||||||
|
|
||||||
|
//文字列前後の空白を除去
|
||||||
|
System.out.println(str.strip());
|
||||||
|
|
||||||
|
//文字数を数える
|
||||||
|
int count = str.length();
|
||||||
|
|
||||||
|
|
||||||
|
//0字だった場合
|
||||||
|
if(str.isBlank()){
|
||||||
|
System.out.println("何も入力されていません");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//140字以上だった場合
|
||||||
|
else if(count >= 140) {
|
||||||
|
System.out.println("投稿文が長すぎます");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
|
||||||
|
//投稿完了する
|
||||||
|
System.out.println("↓↓↓↓↓↓ 投稿されました ↓↓↓↓↓↓");
|
||||||
|
|
||||||
|
//入力した文章を表示
|
||||||
|
System.out.println(str);
|
||||||
|
|
||||||
|
//終了
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user