2015 Java Chapter 10 (Week 11)

From: 2015-11-02 00:00:00 To: 2015-12-07 00:00:00 Now: 2024-11-21 23:56:39 Status: Public

H - MyCharacter 클래스

Time Limit: 1s Memory Limit: 128MB

Snippet Judge Submissions: 544 Solved: 370
Description

샘플 입력에 대해서 샘플 아웃풋과 같은 결과를 보여주는 MyCharacter를 만들자. The Character class is provided in the Java library. Provide your own implementation for this class. Name the new class MyCharacter.

Input

* Line 1 : 테스트케이스 T (1~1,000)

* Line 2 ~ T+1 : 문자

 

Output

* Line 1 ~ 12T : 각 테스트 케이스마다 샘플 출력과 같이 12줄씩 출력

 

Sample Code
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int T = sc.nextInt();
        for (int t = 0; t < T; t++) {
            char ch = sc.next().charAt(0);
            MyCharacter c = new MyCharacter(ch);
            System.out.println(c.charValue());
            System.out.println(c.compareTo(new MyCharacter('i')));
            System.out.println(c.equals(new MyCharacter('i')));
            System.out.println(c.isDigit());
            System.out.println(c.isDigit(ch));
            System.out.println(MyCharacter.isDigit(ch));
            System.out.println(MyCharacter.isLetter(ch));
            System.out.println(MyCharacter.isLetterOrDigit(ch));
            System.out.println(MyCharacter.isLowerCase(ch));
            System.out.println(MyCharacter.isUpperCase(ch));
            System.out.println(MyCharacter.toUpperCase(ch));
            System.out.println(MyCharacter.toLowerCase(ch));
        }
    }
}

YOUR_CODE
Sample Input
3
1
i
Z
Sample Output
1
-56
false
true
true
true
false
true
false
false
1
1
i
0
true
false
false
false
true
true
true
false
I
i
Z
-15
false
false
false
false
true
true
false
true
Z
z
Source

JAVA2015 PE10.24