본문 바로가기

728x90
반응형

프로그래밍

(122)
[자바] 정올 633 : 반복제어문1 - 자가진단6 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int i; boolean a = true; while(a){ System.out.print("1. Korea\n" + "2. USA\n" + "3. Japan\n" + "4. China\n" + "number? "); i = sc.nextInt(); switch(i){ case 1: System.out.println("\nSeoul"); break; case 2: System.out.println("\nWashington"); break; case 3: System.out.printl..
[자바] 정올 540 : 반복제어문1 - 자가진단5 import java.util.Scanner; public class Main { public static void main(String[] args) { int i; Scanner sc = new Scanner(System.in); while(true){ i = sc.nextInt(); if(i == -1) break; if(i % 3 == 0) System.out.println(i/3); } } }
[자바] 정올 539 : 반복제어문1 - 자가진단4 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int i, sum = 0, count = 0; while(true){ i = sc.nextInt(); sum += i; count++; if(i >= 100) break; } System.out.printf("%d\n%.1f", sum, (double)sum / count); } }
[자바] 정올 538 : 반복제어문1 - 자가진단3 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a; while(true){ System.out.print("number? "); a = sc.nextInt(); if(a == 0) break; if(a > 0) System.out.println("positive integer"); else System.out.println("negative number"); } } }
[자바] 정올 537 : 반복제어문 - 자가진단2 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int i = 1; int sum = 0; while(i
[자바] 정올 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."); } } }

728x90
반응형