Advertisement
Guest User

Untitled

a guest
May 25th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6.  
  7. /**
  8. *
  9. * @author hypemonkieboi
  10. */
  11. public class BMICalculator {
  12. //define instance variables or fields or attributes
  13. private String name;
  14. private double weight;
  15. private double height;
  16. public BMICalculator(String name, double weight, double height)
  17. {
  18. this.name = name;
  19. this.weight = weight;
  20. this.height = height;
  21. }
  22. public String getName()
  23. {
  24. return name;
  25. }
  26. public double getWeight()
  27. {
  28. return weight;
  29. }
  30. public double getHeight()
  31. {
  32. return height;
  33. }
  34. public void setName(String n)
  35. {
  36. name = n;
  37. }
  38. public void setweight(double w)
  39. {
  40. weight = w;
  41. }
  42. public void setHeight(double h)
  43. {
  44. height = h;
  45. }
  46. public String calculateBMIandPrintCategory(String n, double w, double h) {
  47. double bmi = (weight / (height * height)) * 703;
  48. String bmiCategory = "";//assign an empty string
  49. if(bmi >= 40)
  50. {
  51. bmiCategory = "Morbid Obese";
  52. }
  53. else if(bmi > 35 && bmi < 40)
  54. {
  55. bmiCategory = "Severely Obese";
  56. }
  57. else if (bmi > 30 && bmi < 35)
  58. {
  59. bmiCategory = "Obese";
  60. }
  61. else if(bmi > 25 && bmi < 30)
  62. {
  63. bmiCategory = "Overweight";
  64. }
  65. else if (bmi > 18.5 && bmi < 25)
  66. {
  67. bmiCategory = "Normal";
  68. }
  69. else
  70. {
  71. bmiCategory = "Underweight";
  72. }
  73. return bmiCategory;
  74. }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement