본문 바로가기

728x90
반응형

전체 글

(187)
[자바] 정올 536 : 반복제어문1 - 자가진단1 public class Main { public static void main(String[] args) { int i =1; while(true){ System.out.print(i + " "); i++; if(i==16)break; } } }
[자바] 정올 124 : 선택제어문 - 형성평가5 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int mon = sc.nextInt(); int[] arr = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; System.out.println(arr[mon-1]); } }
[자바] 정올 123 : 선택제어문 - 형성평가4 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.print("Number? "); int a = sc.nextInt(); switch(a){ case 1: System.out.println("dog"); break; case 2: System.out.println("cat"); break; case 3: System.out.println("chick"); break; default: System.out.println("I don't know."); } } }
[자바] 정올 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; } } }

728x90
반응형