package p01;
import java.util.Scanner;
public class BMI {
public static void main(String[] args) {
while (true) {
System.out.println("請輸入身高");
Scanner sc = new Scanner(System.in);
float cm = sc.nextFloat(); //輸入浮點數
System.out.println("你輸入的身高是"+cm);
System.out.println("請輸入體重");
float kg = sc.nextFloat();//輸入浮點數
System.out.println("你輸入的體重是"+kg);
float m = cm / 100.0f;
float bmi = kg / (m*m);
System.out.println("---------------");
System.out.println("BMI="+bmi);
System.out.println("是否繼續?1.是2.否");
int again = sc.nextInt();
if (again==2) {
break;
}
System.out.println("再執行一次");
}
System.out.println("---------------");
System.out.println("程式結束");
}
}