Discuss / Java / my ans

my ans

Topic source

少年__A

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

package com.itranswarp.learnjava;

import java.util.Scanner;

/**

 * 计算BMI

 */

public class Main {

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

System.out.print("Height (m): ");

double height = scanner.nextDouble();

System.out.print("Weight (kg): ");

double weight = scanner.nextDouble();

// FIXME:

double bmi = weight/(height*height);

// TODO: 打印BMI值及结果

System.out.printf("Your bmi is:%.2f, you are", bmi);

if (bmi > 32) {

System.out.print("very fat.");

}else if (bmi >= 28) {

System.out.print("fat.");

}else if (bmi >= 25) {

System.out.print("heavy.");

}else if (bmi >=18.5) {

System.out.print("normal.");

}else {

System.out.print("light.");

}

}

}


  • 1

Reply