Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class BMI {
  4.  
  5. public static void main(String [] args) {
  6.  
  7. Scanner input = new Scanner (System.in);
  8.  
  9. System.out.print("Enter your weight (kg): ");
  10. double weight = input.nextDouble();
  11.  
  12. System.out.print("Enter your height (m): ");
  13. double height = input.nextDouble();
  14.  
  15. double bmi = weight/(height*height);
  16.  
  17. double low_normal = 18.5 * (height*height);
  18.  
  19. double high_normal = 25 * (height*height);
  20.  
  21. String result = "A";
  22. double gainlose = 0;
  23.  
  24. if (bmi < 15){
  25. result = "extremely underweight";
  26. gainlose = low_normal - weight;
  27. }
  28. else if (15.0 <= bmi && bmi < 18.5){
  29. result = "underweight";
  30. gainlose = low_normal - weight;
  31. }
  32. else if (18.5 <= bmi && bmi < 25.0){
  33. result = "normal weight";
  34. }
  35. else if (bmi <= 30){
  36. result = "overweight";
  37. gainlose = weight - high_normal;
  38. }
  39. else if (bmi <= 35.0 ){
  40. result = "obese";
  41. gainlose = weight - high_normal;
  42. }
  43. else if (bmi > 35){
  44. result = "extremely obese";
  45. gainlose = weight - high_normal;
  46. }
  47. if (bmi < 18.5)
  48. System.out.printf("Your BMI is %.2f and that mean %s you have to gain %.2f%n",bmi,result,gainlose);
  49.  
  50. else if (18.5 <= bmi && bmi < 25.0)
  51. System.out.printf("Your BMI is %.2f and that mean %s%n",bmi,result);
  52.  
  53. else if (bmi > 25)
  54. System.out.printf("Your BMI is %.2f and that mean %s you have to lose %.2f%n",bmi,result,gainlose);
  55.  
  56.  
  57.  
  58.  
  59. }
  60.  
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement