Algorithm
[5622] 문자열 - 다이얼
jaamong
2022. 4. 20. 14:42
문제
코드
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException {
//buffer와 switch-case를 사용한 방법 외 다른 방법
int cnt = 0;
int input;
while (true) {
input = System.in.read();
if (input == '\n')
break;
if (input < 68) cnt += 3;
else if (input < 71) cnt += 4;
else if (input < 74) cnt += 5;
else if (input < 77) cnt += 6;
else if (input < 80) cnt += 7;
else if (input < 84) cnt += 8;
else if (input < 87) cnt += 9;
else cnt += 10;
}
System.out.print(cnt);
}
}