2日目
This commit is contained in:
@@ -5,7 +5,7 @@ public class StringCheck_20261007福森 {
|
||||
public static void main(String[] args) {
|
||||
// TODO 自動生成されたメソッド・スタブ
|
||||
|
||||
//段階1
|
||||
//画面に「いまなにしてる?」を表示する
|
||||
args = new String [4];
|
||||
|
||||
args[0] = "いまなにしてる?";
|
||||
@@ -14,40 +14,53 @@ public class StringCheck_20261007福森 {
|
||||
args[3] = "↓↓↓↓↓↓ 投稿されました ↓↓↓↓↓↓";
|
||||
System.out.println(args[0]);
|
||||
|
||||
//段階2
|
||||
//文字列を入力させる
|
||||
Scanner sc = new Scanner(System.in);
|
||||
String str = sc.next();
|
||||
|
||||
String text = str;
|
||||
System.out.println("");
|
||||
String text = str;
|
||||
|
||||
System.out.println(args[3]);
|
||||
System.out.println(str);
|
||||
|
||||
//段階3
|
||||
//文字数を数える
|
||||
int count = text.length();
|
||||
System.out.println(count);
|
||||
//空文字判定:str の文字数が 0 かどうか
|
||||
boolean num;
|
||||
int nums = count;
|
||||
|
||||
//空文字判定:str の文字数が 0 かどうか
|
||||
boolean num;
|
||||
int nums = count;
|
||||
|
||||
num = (nums == 0);
|
||||
System.out.println(num);
|
||||
|
||||
//文字数超過判定:str の文字数が 140 を超えるかどうか
|
||||
boolean num2;
|
||||
int nums2 = count;
|
||||
|
||||
num2 = (nums2 >= 140);
|
||||
System.out.println(num2);
|
||||
num = (nums == 0);
|
||||
System.out.println(num);
|
||||
|
||||
//「残り入力可能文字数(140 - 文字数)」
|
||||
int rest;
|
||||
rest = 140 - count;
|
||||
System.out.println(rest);
|
||||
|
||||
|
||||
}
|
||||
//文字数超過判定:str の文字数が 140 を超えるかどうか
|
||||
boolean num2;
|
||||
int nums2 = count;
|
||||
|
||||
num2 = (nums2 >= 140);
|
||||
System.out.println(num2);
|
||||
|
||||
}
|
||||
//「残り入力可能文字数(140 - 文字数)」
|
||||
int rest;
|
||||
rest = 140 - count;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user