当前位置:   article > 正文

新手.双向if语句简单运用_两个if语句

两个if语句
  1. //体重标准测试
  2. import java.util.Scanner;
  3. public class Study4 {
  4. public static void main(String[] args) {
  5. Scanner input = new Scanner(System.in);
  6. System.out.print("Enter weight in pounds (kg) : ");
  7. double weight = input.nextDouble();
  8. System.out.print("Enter height in inches (m) : ");
  9. double height = input.nextDouble();
  10. double bmi = weight / (height * height);
  11. System.out.println("Your BMI is " + bmi);
  12. if (bmi < 16)
  13. System.out.println("轻度偏瘦");
  14. else if (bmi < 24)
  15. System.out.println("正常体重");
  16. else if (bmi < 27)
  17. System.out.println("体重过重");
  18. else if (bmi < 30)
  19. System.out.println("轻度肥胖");
  20. else if (bmi < 35)
  21. System.out.println("中度肥胖");
  22. else
  23. System.out.println("严重肥胖");
  24. }}

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号