Advertisement
willieshi232

Untitled

Oct 18th, 2015
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. import java.util.*;
  2. public class BMI
  3. {
  4. public static void main(String args[])
  5. {
  6. Scanner pikachu = new Scanner(System.in);
  7. System.out.println("This program reads data for two people and \ncomputes their body mass index(BMI)");
  8. System.out.print("Input the height of your first person in inches");
  9. double height1 = pikachu.nextDouble();
  10. System.out.print("Input the weight of your first person in pounds");
  11. double weight1 = pikachu.nextDouble();
  12. System.out.println();
  13. System.out.print("Input the height of the second person in inches");
  14. double height2 = pikachu.nextDouble();
  15. System.out.print("Input the weight of the second person in pounds");
  16. double weight2 = pikachu.nextDouble();
  17. double BMI1 = Calculation1(height1, weight1);
  18. double BMI2 = Calculation2(height2, weight2);
  19. System.out.println("Person 1 BMI =" + BMI1);
  20. if(BMI1 >= 30){
  21. System.out.println("obese");
  22. } else if(25.0 <= BMI1 && BMI1 <= 29.9)
  23. {
  24. System.out.println("overweight");
  25. } else if(18.5 <= BMI1 && BMI1 <= 24.9){
  26. System.out.println("normal");
  27. } else{ // BMI1 < 18.5
  28. System.out.println("underweight");
  29. }
  30. System.out.println("Person 2 BMI =" + BMI2);
  31. if(BMI2 >= 30){
  32. System.out.println("obese");
  33. } else if(25.0 <= BMI2 && BMI2 <= 29.9)
  34. {
  35. System.out.println("overweight");
  36. } else if(18.5 <= BMI2 && BMI2 <= 24.9){
  37. System.out.println("normal");
  38. } else{ // BMI2 <18.5
  39. System.out.println("underweight");
  40. }
  41. double Difference = (BMI1-BMI2);
  42. System.out.println("Difference =" + Difference);
  43. }
  44. public static double Calculation1(double height1, double weight1)
  45. {
  46. double BMI1 = (weight1/(height1*height1)*703);
  47. return BMI1;
  48. }
  49. public static double Calculation2( double height2, double weight2)
  50. {
  51. double BMI2 = (weight2/(height2*height2)*703);
  52. return BMI2;
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement