프로그래밍 (122) 썸네일형 리스트형 [자바] 정올 122 : 선택제어문 - 형성평가3 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int year = sc.nextInt(); if(year % 400 == 0) System.out.println("leap year"); else if(year % 4 == 0 && year % 100 != 0) System.out.println("leap year"); else System.out.println("common year"); } } [자바] 정올 121 : 선택제어문 - 형성평가2 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); if(a > 0) System.out.println("plus"); else if( a == 0) System.out.println("zero"); else System.out.println("minus"); } } [자바] 정올 120 : 선택제어문 - 형성평가1 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(), b = sc.nextInt(); int min = a > b ? b : a; int max = min == a ? b:a; System.out.println(max - min); } } [자바] 정올 632 : 선택제어문 - 자가진단9 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(),b = sc.nextInt(),c = sc.nextInt(); int min = a > b ? b : a; min = min > c ? c : min; System.out.println(min); } } [자바] 정올 535 : 선택제어문 - 자가진단8 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); double grade = sc.nextDouble(); switch ((int)grade){ case 4: System.out.println("scholarship"); break; case 3: System.out.println("next semester"); break; case 2: System.out.println("seasonal semester"); break; case 1: System.out.println("retake"); break; } } } [자바] 정올 534 : 선택제어문 - 자가진단7 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); char ch = sc.next().charAt(0); switch(ch){ case 'A': System.out.println("Excellent"); break; case 'B': System.out.println("Good"); break; case 'C': System.out.println("Usually"); break; case 'D': System.out.println("Effort"); break; case 'F': System.out.println("Failure"); .. [자바] 정올 533 : 선택제어문 - 자가진단6 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); char S = sc.next().charAt(0); int age = sc.nextInt(); if (age < 18) { if (S == 'M') System.out.println("BOY"); else System.out.println("GIRL"); } else { if (S == 'M') System.out.println("MAN"); else System.out.println("WOMAN"); } } } [자바] 정올 532 : 선택제어문 - 자가진단5 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); double a = sc.nextDouble(), b = sc.nextDouble(); if(a >= 4.0 && b >= 4.0) System.out.println('A'); else if(a >= 3.0 && b >= 3.0) System.out.println('B'); else System.out.println('C'); } } 이전 1 ··· 5 6 7 8 9 10 11 ··· 16 다음