- import java.util.Scanner;
- public class ch17{
- public static void main(String args[]){
- Scanner s = new Scanner(System.in);
- Float a , b , bmi ;
- System.out.print("請輸入您的體重?");
- a = s.nextFloat();
- System.out.print("請輸入您的身高?");
- b = s.nextFloat();
- b = b/100;
- bmi = a/(b*b);
- 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 && bmi<27){
- System.out.println("您體重=>過重!");
- }else if (bmi>=27 && bmi<30){
- System.out.println("您體重=>輕度肥胖!");
- }else if (bmi>=30 && bmi<35){
- System.out.println("您體重=>中度肥胖!");
- }else{
- System.out.println("您體重=>重度肥胖!");
- }
- }
- }
複製代碼 |