본문 바로가기

Java/과제

chapter03) 연산자 example - 2가지 조건 중 하나를 만족할 때 문구가 나타나는 프로그램

package Chapter03;

import java.util.Scanner;

public class exercise32 {
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		System.out.print("수도입니까?(수도: 1, 수도아님: 0) ");
		int c1 = scanner.nextInt();

		System.out.print("총 인구는?(단위: 만) ");
		int t1 = scanner.nextInt();

		System.out.print("연소득이 1억 이상인 인구는?(단위: 만) ");

		int p1 = scanner.nextInt();

		String metro = ((c1 == 1) && (t1 >= 100)) || (p1 >= 50) ? "입니다." : "가 아닙니다.";

		System.out.println("이 도시는 메트로폴리스" + metro);

	}
}
Recent Posts
Popular Posts
Tags
더보기
Recent Comments