1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | /* * 두 개의 정수를 입력받아 큰값과 작은 값을 출력하는 프로그램을 구현하시오. * <입력형식> * 첫번째수 = * 두번째수 = * * <출력형식> * 큰수 = * 작은수 = * */ import java.io.*; public class Exam_02 { public static void main(String[] ar) throws IOException{ int first, second, third, max, min; BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); System.out.print("첫번째수 = "); first = Integer.parseInt(in.readLine()); System.out.print("두번째수 = "); second = Integer.parseInt(in.readLine()); System.out.print("세번째수 = "); third = Integer.parseInt(in.readLine()); if(first > second && first > third){ max = first; if(second > third){ min = third; }else{ min = second; } }else if(second > first && second > third){ max = second; if(first > third){ min = third; }else{ min = first; } }else{ max = third; if(first > second){ min = second; }else{ min = first; } } System.out.println(); System.out.println("큰수 = " + max); System.out.println("작은수 = " + min); } } | cs |
'공부 > JAVA_source' 카테고리의 다른 글
자바 세개의 정수 입력받아 큰 순서대로 나열 (0) | 2016.10.24 |
---|---|
대소관계 비교 (0) | 2016.10.24 |
숫자를 입력받아 양수인지 판정 (0) | 2016.10.24 |
[자바] 점수를 입력받아 성적처리 (총점/평균 계산) (0) | 2016.10.24 |
[자바] 문자를 입력받아 아스키코드 값 표시 (0) | 2016.10.24 |