标签:style blog color java io ar div log
import javax.swing.JOptionPane; public class Health { public static void main(String[] args){ double weight,height; String input = JOptionPane.showInputDialog(null,"请输入您的体重","对话框",JOptionPane.QUESTION_MESSAGE); String input1 = JOptionPane.showInputDialog(null,"请输入您的身高","对话框",JOptionPane.QUESTION_MESSAGE); double a = Double.parseDouble(input); double b = Double.parseDouble(input1); weight = a * 0.45359237; height = b * 0.0254; System.out.println("BMI is " + (int)(weight / Math.pow((height),2) * 100) / 100.00); } }
BMI值通过体重(公斤)除以身高(米)的平方得到,编写程序,提示输入用户体重(磅)和身高(英寸),然后显示BMI
一磅等于0.45359237公斤,一英寸等于0.0254米。
标签:style blog color java io ar div log
原文地址:http://www.cnblogs.com/Amoxicil/p/3895354.html