Advertisement
Guest User

Untitled

a guest
Oct 6th, 2015
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. //NAME: Aaron Chestnut
  2. //Assignment: HOMEWORK 4
  3. //DUE DATE: TUE OCT 6 2015
  4. using System;
  5.  
  6. public class BodyIndex
  7. {
  8. string name;
  9. int height;
  10. double bodymass;
  11.  
  12. public string getName()
  13. {
  14. return name;
  15. }
  16.  
  17. public void setName(string x)
  18. {
  19. x = name;
  20. }
  21.  
  22. public int getHeight()
  23. {
  24. return height;
  25. }
  26.  
  27. public void setHeight(int y)
  28. {
  29. y = height;
  30. }
  31.  
  32. public BodyIndex(int a, string b)
  33. {
  34. setName(b);
  35. setHeight(a);
  36. }
  37.  
  38. public void calculateBmi(int weight)
  39. {
  40. bodymass = weight* 703 / (getHeight() * getHeight());
  41. if (bodymass < 18.5)
  42. {
  43. Console.WriteLine("Name: {0}", getName());
  44. Console.WriteLine("Weight: {0}", weight);
  45. Console.WriteLine("Height: {0}", getHeight());
  46. Console.WriteLine("BMI: {0}", bodymass);
  47. Console.WriteLine("Result: Below Optimal");
  48.  
  49. }
  50. else if (bodymass > 25)
  51. {
  52. Console.WriteLine("Name: {0}", getName());
  53. Console.WriteLine("Weight: {0}", weight);
  54. Console.WriteLine("Height: {0}", getHeight());
  55. Console.WriteLine("BMI: {0}", bodymass);
  56. Console.WriteLine("Result: Above Optimal");
  57.  
  58. }
  59. else
  60. {
  61. Console.WriteLine("Name: {0}", getName());
  62. Console.WriteLine("Weight: {0}", weight);
  63. Console.WriteLine("Height: {0}", getHeight());
  64. Console.WriteLine("BMI: {0}", bodymass);
  65. Console.WriteLine("Result: Optimal");
  66.  
  67. }
  68. }
  69.  
  70. public class testbmi
  71. {
  72. public static void Main(string[] args)
  73. {
  74. BodyIndex mybmi = new BodyIndex(75,"Aaron Chestnut");
  75. Console.WriteLine("Please enter your weight: ");
  76. mybmi.calculateBmi(Convert.ToInt32(Console.ReadLine()));
  77. Console.ReadKey();
  78. }
  79. }
  80.  
  81.  
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement