java/조건문
최대값 구하기[1단계]
june__Park
2021. 3. 23. 10:19
package week1;
import java.util.Scanner;
public class Day3_8 {
public static void main(String[] args) {
// TODO Auto-generated method stub
/*
* # 최대값 구하기[1단계]
* 1. 숫자 3개를 입력받는다.
* 2. 입력받은 3개의 수를 비교하여,
* 3. 가장 큰 수(MAX)를 출력한다.
*/
Scanner scan = new Scanner(System.in);
System.out.print("Input Number: ");
int num1 = scan.nextInt();
System.out.print("Input Number: ");
int num2 = scan.nextInt();
System.out.print("Input Number: ");
int num3 = scan.nextInt();
int max = num1;
if(max < num2) {
max = num2;
if(max < num3) {
max = num3;
}
}
else if(max < num3) {
max = num3;
}
System.out.println("MAX Value: "+max);
scan.close();
}
}