방치하기

홍대 자바 수업 표준 체중과 자신과의 차이 스캐너 . 본문

홍익대 Java/수업

홍대 자바 수업 표준 체중과 자신과의 차이 스캐너 .

Yi Junho 2009. 7. 21. 17:29
반응형
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
import java.util.*;
 
 
 
class height{
     
         
    public static void main(String [] arg) {
                Scanner scan= new Scanner(System.in);
                System.out.printf("당신의 키를 입력해주세요\n");
                int height=scan.nextInt();
                 
                double normal_weight=(double)((height-100)*0.9);
                System.out.printf("당신의 키에 표준 체중은 : %4.2f kg 입니다" , normal_weight);
                System.out.printf("당신의 몸무게를 입력해주세요\n");
                double weight=scan.nextDouble();
                 
                if (weight==normal_weight)
                {
                    System.out.printf("표준 체중입니다" );
                }
                else if (weight>normal_weight)
                {
                    System.out.printf("표준 체중 초과 입니다 : %4.2f kg 만큼 초과입니다.",weight-normal_weight );
                }
                else
                {
                    System.out.printf("표준 체중 부족 입니다 : %4.2f",normal_weight-weight );
                }
    }
}
                  
                
반응형
Comments