Guest User

Untitled

a guest
Jan 21st, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.00 KB | None | 0 0
  1. import java.util.*;
  2. /**
  3. * Write a description of class HeartRates here.
  4. * This Program will establish the age of a person. From this age the program will calculate the Maximuim
  5. * Heart Rate and Heart Rate range,
  6. * @author Michael Young
  7. * @version (October 1, 2011)
  8. */
  9. public class HeartRates
  10. {
  11. // instance variables
  12. public String FirstName;
  13. public String LastName;
  14. public int bday;
  15. public int bmonth;
  16. public int byear;
  17. public int cyear;
  18.  
  19. private int age;
  20. private double maxiHR;
  21. private double targetminiHR;
  22. private double targetmaxiHR;
  23. //** Starting to attempt to define the constructor.
  24. public HeartRates(String inputFirstName, String inputLastName, int inputBirthDay, int inputBirthMonth,
  25. int inputBirthYear, int inputCurrentYear)
  26. // Constructor with no arguments
  27. {
  28. FirstName = inputFirstName;
  29. LastName = inputLastName;
  30. bday = inputBirthDay;
  31. bmonth = inputBirthMonth;
  32. byear = inputBirthYear;
  33. cyear = inputCurrentYear;
  34.  
  35. }
  36.  
  37. ///** Setting up constructor with arguments.
  38. public HeartRates ()
  39. {
  40. FirstName = "Michael";
  41. LastName = "Young";
  42. bday = 2;
  43. bmonth = 8;
  44. byear = 1989;
  45. cyear = 2011;
  46.  
  47. }
  48. /// Sets
  49. public void setFirst(String inputFirstName)
  50. {
  51. FirstName = inputFirstName;
  52. }
  53.  
  54. public void setLast(String inputLastName)
  55. {
  56. LastName = inputLastName;
  57. }
  58.  
  59. public void setbday(int inputBirthDay)
  60. {
  61. bday = inputBirthDay;
  62. }
  63.  
  64. public void setbmonth(int inputBirthMonth)
  65. {
  66. bmonth = inputBirthMonth;
  67. }
  68.  
  69. public void setbyear(int inputBirthYear)
  70. {
  71. byear = inputBirthYear;
  72. }
  73.  
  74. public void setcyear(int inputCurrentYear)
  75. {
  76. cyear = inputCurrentYear;
  77. }
  78.  
  79. //gets
  80.  
  81. public String getFirst()
  82. {
  83. return FirstName;
  84. }
  85.  
  86. public String getLast()
  87. {
  88. return LastName;
  89. }
  90.  
  91. public int getbday()
  92. {
  93. return bday;
  94. }
  95.  
  96. public int getbmonth()
  97. {
  98. return bmonth;
  99. }
  100.  
  101. public int getbyear()
  102. {
  103. return byear;
  104. }
  105.  
  106. public int getcyear()
  107. {
  108. return cyear;
  109. }
  110.  
  111.  
  112. /// Methods for calculating
  113.  
  114. public int calculateage()
  115. {
  116.  
  117. age = cyear-byear;
  118. return age;
  119.  
  120. }
  121.  
  122.  
  123. public double maximumHR()
  124. {
  125. maxiHR = 220 - age;
  126. return maxiHR;
  127. }
  128.  
  129.  
  130. public double targetminimumhr()
  131. {
  132. targetminiHR = maxiHR * .5;
  133. return targetminiHR;
  134. }
  135.  
  136.  
  137. public double targetmaximumhr()
  138. {
  139. targetmaxiHR = maxiHR * .85;
  140. return targetmaxiHR;
  141. }
  142.  
  143.  
  144.  
  145. public void main(String arg[]){
  146.  
  147. String FirstName;
  148. String LastName;
  149. int bday;
  150. int bmonth;
  151. int byear;
  152. int cyear;
  153.  
  154.  
  155. Scanner input = new Scanner(System.in);
  156. System.out.print( "Enter First Name: ");
  157. FirstName = input.next();
  158. System.out.print ("Enter Last Name: ");
  159. LastName = input.next();
  160. System.out.print ("Enter Birthyear: ");
  161. byear = input.nextInt ();
  162. System.out.print ("Enter Birth Month: ");
  163. bmonth = input.nextInt ();
  164. System.out.print ("Enter Birth Day: ");
  165. bday = input.nextInt();
  166. System.out.print ("Enter Current Year: ");
  167. cyear = input.nextInt();
  168.  
  169. HeartRates a = new HeartRates();
  170.  
  171. System.out.println("Patient's Name: " + FirstName() + LastName());
  172. System.out.println("Patient's Age: " + a.calculateage());
  173. System.out.println("Patients Maximum Heart Rate:" + a.maximumHR());
  174. System.out.println("Patients Target Heart Rate:" + a.minimumHR() " - " a.maximumHR());
  175.  
  176. }
  177. }
Add Comment
Please, Sign In to add comment