Advertisement
zainarfi00

BMI Project

Oct 18th, 2015
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.63 KB | None | 0 0
  1. /**
  2. *BMI Project
  3. *
  4. * Zain Arfi
  5. * @version (a version number or a date)
  6. */
  7. import java.util.*;
  8. public class BMI_Project
  9. {
  10. public static void main(String[] args)
  11. {
  12. Scanner console = new Scanner(System.in);
  13. System.out.println("What is person one's height in inches?");
  14. int height1 = console.nextInt();
  15. System.out.println("What is person two's height in inches");
  16. int height2 = console.nextInt();
  17. System.out.println("What is person one's weight in pounds?");
  18. int weight1 = console.nextInt();
  19. System.out.println("What is person two's weight in pounds?");
  20. Calculate(height1, height2, weight1, weight2);
  21.  
  22. }
  23. public static string Calculate(int h1, int h2, int w1, int w2)
  24. {
  25. double Bmi1 = w1 / (h1 * h1) * 703;
  26. double Bmi2 = w2 / (h2 * h2) * 703;
  27. double diff = Math.abs(Bmi1 - Bmi2);
  28. return(
  29. if((Bmi1 >= 30))
  30. {
  31. System.out.println("Person 1 BMI =" + Bmi1);
  32. System.out.println("obese");
  33. }
  34. else if((Bmi1 >= 25) && (Bmi1 <= 29.9))
  35. {
  36. System.out.println("Person 1 BMI =" + Bmi1);
  37. System.out.println("overweight");
  38. }
  39. else if((Bmi1 >=18.5) && (Bmi1 <= 24.9))
  40. {
  41. System.out.println("Person 1 BMI =" + Bmi1);
  42. System.out.println("normal");
  43. }
  44. else if((Bmi1 <= 18.5))
  45. {
  46. System.out.println("Person 1 BMI =" + Bmi1);
  47. System.out.println("underweight");
  48. }
  49. else if((Bmi2 >= 30))
  50. {
  51. System.out.println("Person 2 BMI =" + Bmi1);
  52. System.out.println("obese");
  53. }
  54. else if((Bmi2 >= 25) && (Bmi2 <= 29.9))
  55. {
  56. System.out.println("Person 2 BMI =" + Bmi1);
  57. System.out.println("overweight");
  58. }
  59. else if((Bmi2 >=18.5) && (Bmi2 <= 24.9))
  60. {
  61. System.out.println("Person 2 BMI =" + Bmi1);
  62. System.out.println("normal");
  63. }
  64. else if(Bmi2 <= 18.5)
  65. {
  66. System.out.println("Person 2 BMI =" + Bmi1);
  67. System.out.println("underweight");
  68. }
  69. System.out.println("Difference =" + diff);
  70. );
  71. }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement