hanker

백준(5622) JAVA - 다이얼 본문

Study/ALGORITHM

백준(5622) JAVA - 다이얼

hanker 2021. 1. 5. 09:38
반응형
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		String str = sc.nextLine();
		
		int sum = 0;
		
		for(int i = 0 ; i < str.length(); i++) {
			char chr = str.charAt(i);
			
			if((int)chr <= 67) {
				sum = sum + 3;
			} else if((int) chr <= 70) {
				sum = sum + 4;
			} else if((int) chr <= 73) {
				sum = sum + 5;
			} else if((int) chr <= 76) {
				sum = sum + 6; 
			} else if((int) chr <= 79) {
				sum = sum + 7;
			} else if((int) chr <= 83) {
				sum = sum + 8;
			} else if((int) chr <= 86) {
				sum = sum + 9;
			} else if((int) chr <= 90) {
				sum = sum + 10;
			}
		}
		System.out.println(sum);
	}

}
반응형