2日目
This commit is contained in:
47
StringCheck20261008_ishikawa.java
Normal file
47
StringCheck20261008_ishikawa.java
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
package mission;
|
||||||
|
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class StringCheck {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// TODO 自動生成されたメソッド・スタブ
|
||||||
|
String[] a;
|
||||||
|
a = new String[4];
|
||||||
|
a[0] = "いまなにしてる?";
|
||||||
|
a[1] = "何も入力されていません";
|
||||||
|
a[2] = "投稿文が長すぎます";
|
||||||
|
a[3] = "↓↓↓↓↓↓ 投稿されました ↓↓↓↓↓↓";
|
||||||
|
|
||||||
|
Scanner sc = new Scanner(System.in);
|
||||||
|
String str;
|
||||||
|
while(true) {
|
||||||
|
System.out.println(a[0]);
|
||||||
|
str = sc.nextLine().strip();
|
||||||
|
System.out.println(str);
|
||||||
|
|
||||||
|
boolean b1 = str.length() == 0;
|
||||||
|
boolean b2 = str.length() > 140;
|
||||||
|
int n = 140 - str.length();
|
||||||
|
|
||||||
|
if(b1) {
|
||||||
|
System.out.println(a[1]);
|
||||||
|
continue;
|
||||||
|
}else if(b2) {
|
||||||
|
System.out.println(a[2]);
|
||||||
|
continue;
|
||||||
|
}else {
|
||||||
|
System.out.println(b1);
|
||||||
|
System.out.println(b2);
|
||||||
|
System.out.println(n);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println();
|
||||||
|
System.out.println(a[3]);
|
||||||
|
System.out.println(str);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user