백준 #4458번 첫 글자를 대문자로

jhj·2024년 5월 25일

백준 JAVA

목록 보기
498/583
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		sc.nextLine();
		for(int i = 0; i < n; i++) {
			String a = sc.nextLine();
			if('a' <= a.charAt(0) && a.charAt(0) <= 'z') {
				System.out.print((char)(a.charAt(0) - 32));
			}else if('A' <= a.charAt(0) && a.charAt(0) <= 'Z') {
				System.out.print((char)(a.charAt(0)));
			}
			
			for(int j = 1; j < a.length(); j++) {
				System.out.print(a.charAt(j));
			}
			System.out.println();
		}
		sc.close();
	}
}
profile
개발자를 꿈꾸는

0개의 댓글