๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
SWEA

[SWEA] 2047. ์‹ ๋ฌธ ํ—ค๋“œ๋ผ์ธ

by JulesJ 2022. 5. 17.
728x90

2047. ์‹ ๋ฌธ ํ—ค๋“œ๋ผ์ธ - D1

 

์•„์Šคํ‚ค์ฝ”๋“œ๋ฅผ ์ด์šฉํ•ด์„œ ์†Œ๋ฌธ์ž๋ฅผ ๋Œ€๋ฌธ์ž๋กœ ๋ฐ”๊ฟ”์ค„ ์ˆ˜ ์žˆ๋Š” if๋ฌธ์„ ์ด์šฉํ–ˆ๋‹ค.

์†Œ๋ฌธ์ž a๊ฐ€ 97์ด๋ผ 97๋ณด๋‹ค ํฌ๊ฑฐ๋‚˜ ๊ฐ™์„ ๊ฒฝ์šฐ a์™€ A - ์•ŒํŒŒ๋ฒณ ๋Œ€์†Œ๋ฌธ์ž ์ฐจ์ด๋งŒํผ ๋นผ์คฌ๋‹ค.

 

ํ•˜์ง€๋งŒ ์ž๋ฐ”๋Š”.. ๊ฐ„๋‹จํ•˜๊ฒŒ ๋ฐ”๋กœ ์ด์šฉํ•  ์ˆ˜ ์žˆ๋Š” ํ•จ์ˆ˜๋ฅผ ์ œ๊ณต ์ค‘์ด๋ผ ๊ทธ๊ฑธ๋กœ๋„ ํ’€์–ด๋ณด์•˜๋‹ค..

 

import java.util.Scanner;
import java.io.FileInputStream;

class Solution
{
	public static void main(String args[]) throws Exception
	{
		Scanner sc = new Scanner(System.in);
		String sentense = sc.next();

		for(int i = 0; i < sentense.length(); i++)
		{
			char s = sentense.charAt(i);
			if((int)s >= 97){
				System.out.print((char)(s-32));
			}else{
				System.out.print(s);
			}	
		}
	}
}

 

String์˜ toUpperCase ํ•จ์ˆ˜๋ฅผ ์ด์šฉํ•˜๋ฉด ์œ„์— ๋ช‡์ค„์„ ํ•œ ์ค„๋กœ ์ค„์ผ ์ˆ˜ ์žˆ๋‹ค..!

import java.util.Scanner;
import java.io.FileInputStream;

class Solution
{
	public static void main(String args[]) throws Exception
	{
		Scanner sc = new Scanner(System.in);
		String sentense = sc.next();
		System.out.println(sentense.toUpperCase());
	}
}

 

 

๋ ๐Ÿง

๋Œ“๊ธ€