반응형
연세대학교
문제

연세대학교의 영문명은 YONSEI, 슬로건은 Leading the Way to the Future이다.
이를 출력하는 프로그램을 작성해보도록 하자.
입력
첫째 줄에 N이 주어진다. (N = 0 또는 1)
출력
- N = 0일 경우: 연세대학교의 영문명을 출력한다.
- N = 1일 경우: 연세대학교의 슬로건을 출력한다.
대소문자 구별에 주의하도록 하자.
예제 입력 1 복사
0
예제 출력 1 복사
YONSEI
간단한 삼항연산자로 풀기~
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
String name = "YONSEI";
String slogun = "Leading the Way to the Future";
String result = (N == 0) ? name : slogun;
System.out.println(result);
}
}
반응형
'백준 > 기타 문제' 카테고리의 다른 글
백준 15873 자바 (0) | 2022.04.11 |
---|---|
백준 15726 자바 (0) | 2022.04.11 |
백준 14623 자바 (0) | 2022.04.10 |
백준 14470 자바 (0) | 2022.04.10 |
백준 14264 자바 (0) | 2022.04.10 |