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