---
# System prepended metadata

title: '002if-else結構式  BMI {'

---

#  002if-else結構式  BMI {
public class TestBMI {

	
	public static void main(String[] args) {
		double weight=80,height=1.7;
		double bmi = weight/ Math.pow(height, 2);
		
		System.out.println("BMI="+bmi); 
		
		if  (bmi<18.5) {
			System.out.println("過瘦");
		}else if  (bmi >=18.5 && bmi>24) {
			System.out.println("正常");
		}else if  (bmi>=24)
			System.out.println("過胖");
		}
  }
  
  
  
  ![](https://i.imgur.com/qbDIhUP.png)

