2日目
This commit is contained in:
@@ -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,40 +14,53 @@ 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 かどうか
|
||||||
|
boolean num;
|
||||||
|
int nums = count;
|
||||||
|
|
||||||
//空文字判定:str の文字数が 0 かどうか
|
num = (nums == 0);
|
||||||
boolean num;
|
System.out.println(num);
|
||||||
int nums = count;
|
|
||||||
|
|
||||||
num = (nums == 0);
|
//文字数超過判定:str の文字数が 140 を超えるかどうか
|
||||||
System.out.println(num);
|
boolean num2;
|
||||||
|
int nums2 = count;
|
||||||
|
|
||||||
//文字数超過判定:str の文字数が 140 を超えるかどうか
|
num2 = (nums2 >= 140);
|
||||||
boolean num2;
|
System.out.println(num2);
|
||||||
int nums2 = count;
|
|
||||||
|
|
||||||
num2 = (nums2 >= 140);
|
//「残り入力可能文字数(140 - 文字数)」
|
||||||
System.out.println(num2);
|
int rest;
|
||||||
|
rest = 140 - count;
|
||||||
|
System.out.println(rest);
|
||||||
|
|
||||||
//「残り入力可能文字数(140 - 文字数)」
|
//投稿完了
|
||||||
int rest;
|
System.out.println(args[3]);
|
||||||
rest = 140 - count;
|
System.out.println(str);
|
||||||
System.out.println(rest);
|
|
||||||
|
//ここから
|
||||||
|
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