This commit is contained in:
2026-10-09 11:29:09 +09:00
parent 2355863918
commit 66386dc85e

View File

@@ -5,7 +5,7 @@ public class StringCheck_20261007福森 {
public static void main(String[] args) { public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ // TODO 自動生成されたメソッド・スタブ
//段階1 //画面に「いまなにしてる?」を表示する
args = new String [4]; args = new String [4];
args[0] = "いまなにしてる?"; args[0] = "いまなにしてる?";
@@ -14,20 +14,15 @@ public class StringCheck_20261007福森 {
args[3] = "↓↓↓↓↓↓ 投稿されました ↓↓↓↓↓↓"; args[3] = "↓↓↓↓↓↓ 投稿されました ↓↓↓↓↓↓";
System.out.println(args[0]); System.out.println(args[0]);
//段階2 //文字列を入力させる
Scanner sc = new Scanner(System.in); Scanner sc = new Scanner(System.in);
String str = sc.next(); String str = sc.next();
String text = str; String text = str;
System.out.println("");
System.out.println(args[3]); //文字数を数える
System.out.println(str);
//段階3
int count = text.length(); int count = text.length();
System.out.println(count); System.out.println(count);
//空文字判定:str の文字数が 0 かどうか //空文字判定:str の文字数が 0 かどうか
boolean num; boolean num;
int nums = count; int nums = count;
@@ -47,7 +42,25 @@ public class StringCheck_20261007福森 {
rest = 140 - count; rest = 140 - count;
System.out.println(rest); System.out.println(rest);
//投稿完了
System.out.println(args[3]);
System.out.println(str);
//ここから
System.out.println("いまなにしてる?");
for (int i = 0 ; i < 4; i++) {
System.out.println("今は" + i + "です");
if (i == 2) {
System.out.println("for文を抜けます");
break;
}
}
}
} }
}