class Solution {
public boolean solution(String s) {
boolean answer = true;
char c;
int cToI;
if (s.length() == 4 || s.length() == 6) {
for (int i = 0; i < s.length(); i++) {
c = s.charAt(i);
cToI = (int) c;
if (cToI < 48 || cToI > 57) {
answer = false;
break;
}
}
} else {
answer = false;
}
return answer;
}
}
'프로그래머스' 카테고리의 다른 글
프로그래머스 - 문자열을 정수로 바꾸기 (0) | 2019.01.08 |
---|---|
프로그래머스 - 시저 암호 (0) | 2019.01.08 |
프로그래머스 - K번째수 (0) | 2019.01.08 |
프로그래머스 - 모의고사 (0) | 2019.01.07 |
프로그래머스 - 짝수와 홀수 (0) | 2019.01.07 |