Java 개발자 수업 강의노트/Java 일일 과제
입력받은 세 숫자 중 가장 큰수를 구하는 것
캬캬백곰
2012. 4. 18. 11:53
728x90
#입력받은 세 숫자 중 가장 큰수를 구하는 것
package step3;
import java.util.Scanner;
public class Hw1 {
/**
* @param args
*/
public static void main(String[] args) {
// 세 숫자 중 큰 수를 출력
Scanner sc = new Scanner(System.in);
System.out.println("첫 번째 숫자를 입력");
int a = sc.nextInt();
System.out.println("두 번째 숫자를 입력");
int b = sc.nextInt();
System.out.println("세 번째 숫자를 입력");
int c = sc.nextInt();
int max=a;
if(max<b && b>c){
max=b;
System.out.println(max+ "의 수를 가진 b다.");
}else if(max<c && c>b){
max=c;
System.out.println(max+ "의 수를 가진 c다.");
}else{
System.out.println(max+ "의 수를 가진 a다.");
}
}
}
728x90
반응형