728x90
출처-https://www.acmicpc.net/problem/5622
5622번: 다이얼
첫째 줄에 알파벳 대문자로 이루어진 단어가 주어진다. 단어는 2글자~15글자로 이루어져 있다.
www.acmicpc.net


import java.util.*;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scan=new Scanner(System.in);
String s=scan.next();
int time=0;
for (int i=0;i<s.length();i++) {
char c=s.charAt(i);
if ((c=='A')||(c=='B')||(c=='C'))
time+=3;
else if ((c=='D')||(c=='E')||(c=='F'))
time+=4;
else if ((c=='G')||(c=='H')||(c=='I'))
time+=5;
else if ((c=='J')||(c=='K')||(c=='L'))
time+=6;
else if ((c=='M')||(c=='N')||(c=='O'))
time+=7;
else if ((c=='P')||(c=='Q')||(c=='R')||(c=='S'))
time+=8;
else if ((c=='T')||(c=='U')||(c=='V'))
time+=9;
else
time+=10;
}
System.out.println(time);
}
}728x90
'Problem Solving > BOJ' 카테고리의 다른 글
| [백준, BOJ 1316] 그룹 단어 체커 (java) (0) | 2020.08.29 |
|---|---|
| [백준, BOJ 2941] 크로아티아 알파벳 (java) (0) | 2020.08.29 |
| [백준, BOJ 2908] 상수 (java) (0) | 2020.08.29 |
| [백준, BOJ 1152] 단어의 개수 (java) (0) | 2020.08.27 |
| [백준, BOJ 1157] 단어 공부 (java) (0) | 2020.08.27 |