본문 바로가기

Java/SWEA

[JAVA] SWEA 2547. 신문 헤드라인

https://swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=1&contestProbId=AV5QKsLaAy0DFAUq&categoryId=AV5QKsLaAy0DFAUq&categoryType=CODE&problemTitle=&orderBy=FIRST_REG_DATETIME&selectCodeLang=JAVA&select-1=1&pageSize=10&pageIndex=1

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com

 

 

정답 

 

import java.util.Scanner;

class Solution
{
	public static void main(String args[]) throws Exception
	{	
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		
		StringBuilder sb = new StringBuilder();
		
		for(int i=0; i<str.length(); i++)
		{
			char cur = str.charAt(i);
			
			if(Character.isAlphabetic(cur))
			{
				sb.append(String.valueOf(cur).toUpperCase());
			}
			else
			{
				sb.append(String.valueOf(cur));
			}
		}
		
		System.out.println(sb.toString());
	}
}