헬린코린이

[백준] 5622번 : 다이얼 - JAVA 본문

Programming/Coding Test Practice

[백준] 5622번 : 다이얼 - JAVA

HCD 2023. 4. 15. 22:55

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String Dialing = br.readLine();
		int count = 0;
		for (int i = 0; i < Dialing.length(); i++) {
			int test = Dialing.charAt(i);
			if (test < 68)
				count += 3;
			else if (test < 71)
				count += 4;
			else if (test < 74)
				count += 5;
			else if (test < 77)
				count += 6;
			else if (test < 80)
				count += 7;
			else if (test < 84)
				count += 8;
			else if (test < 87)
				count += 9;
			else if (test < 91)
				count += 10;
		}
		System.out.println(count);
	}
}
Comments