Discuss / Java / 看我写的

看我写的

Topic source

説025

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

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

    Scanner scanner = new Scanner(System.in);

    System.out.println("输入体重(KG)");

    float a =  scanner.nextFloat();

    System.out.println("输入身高(M)");

    float b =  scanner.nextFloat();

    float bmi = a/(b*b);

    System.out.println("BMI="+bmi);

    float d1 = 32;

    float d2 = 28;

    float d3 = 25;

    float d4 = (float)18.5;

    if (bmi>=d1) {

    System.out.println("非常肥胖");

    }

    else if (bmi>=d2) {

    System.out.println("肥胖");

    }

    else if (bmi>=d3){

        System.out.println("偏重");

    }

    else if (bmi>=d3) {

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

    }

    else {

    System.out.println("偏瘦");

    }

    }

}


  • 1

Reply