Discuss / Java / 体重测试

体重测试

Topic source

对酒当歌

#1 Created at ... [Delete] [Delete and Lock User]

import java.util.Scanner;

public class 体重指数 {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        System.out.print("input your weight(kg):");

        double weight = scanner.nextDouble();

        System.out.print("input your height(m):");

        double height = scanner.nextDouble();

        double BMI = ((double) weight / (height * height));

        if (BMI < 18.5) {

            System.out.print("竹竿");

        } else if (BMI >= 18.5 && BMI < 25) {

            System.out.print("正常");

        } else if (BMI >= 25 && BMI < 28) {

            System.out.print("能吃");

        } else if (BMI >= 28 && BMI < 32) {

            System.out.print("超能吃");

        } else if (BMI >= 32) {

            System.out.print("非常能吃");

        }

        scanner.close();

    }

}


  • 1

Reply