Advertisement
jhhar

Untitled

Jan 28th, 2020
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.25 KB | None | 0 0
  1. package jessicahar;
  2.  
  3. import java.util.Scanner;
  4.  
  5. import static jessicahar.Month.Jan;
  6.  
  7. import java.io.File;
  8. import java.io.IOException;
  9.  
  10. enum Month { Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec }
  11.  
  12. //class JessicaHardisurjo_A2 {}
  13. class Date
  14. {
  15. private int Day;
  16. private static Month Month;
  17. private int Year;
  18.  
  19. public Date()
  20. {
  21. Day = 1;
  22. Month = Jan;
  23. Year = 2019;
  24. }
  25.  
  26. public Date(int day, Month month, int year) {
  27. super();
  28. this.Day = day;
  29. this.Month = month;
  30. this.Year = year;
  31.  
  32. }
  33.  
  34. public Date (Date d) {
  35.  
  36. }
  37.  
  38. public int getDay() {
  39. return Day;
  40. }
  41. public void setDay(int day) {
  42. this.Day = day;
  43. }
  44. public Month getMonth() {
  45. return Month;
  46. }
  47. public void setMonth(Month Month) {
  48. this.Month = Month;
  49. }
  50. public int getYear() {
  51. return Year;
  52. }
  53. public void setYear(int Year) {
  54. this.Year = Year;
  55. }
  56.  
  57. public void setDate (int Day, Month Month, int Year)
  58. {
  59. setDay (Day);
  60. setMonth (Month);
  61. setYear (Year);
  62.  
  63. }
  64.  
  65. class HeartRates
  66. {
  67. private String firstName;
  68. private String lastName;
  69. private Date dob;
  70. private int currentYear;
  71. int age;
  72.  
  73. public HeartRates(String firstName, String lastName, Date dob, int currentYear)
  74. {
  75. super();
  76. this.firstName = firstName;
  77. this.lastName = lastName;
  78. this.dob = dob;
  79. this.currentYear = currentYear;
  80.  
  81. }
  82.  
  83. public HeartRates (HeartRates hr) {
  84. }
  85.  
  86. public String getFirstName() {
  87. return firstName;
  88. }
  89.  
  90. public void setFirstName(String firstName) {
  91. this.firstName = firstName;
  92. }
  93.  
  94. public String getLastName() {
  95. return lastName;
  96. }
  97.  
  98. public void setLastName(String lastName) {
  99. this.lastName = lastName;
  100. }
  101.  
  102. public Date getDob() {
  103. return dob;
  104. }
  105.  
  106. public void setDob(Date dob) {
  107. dob.setDate(dob.getDay(), dob.getMonth(), dob.getYear());
  108. }
  109.  
  110. public int getCurrentYear() {
  111. return currentYear;
  112. }
  113.  
  114. public void setCurrentYear(int currentYear) {
  115. this.currentYear = currentYear;
  116. }
  117.  
  118. private int getAge () {
  119. return currentYear - dob.getYear();
  120. }
  121.  
  122. private int getMaximumHeartRate() {
  123. int mhr1 = getAge ();
  124. int mhr2 = 220 - mhr1;
  125. return mhr2;
  126. }
  127.  
  128. private double getMaximumTargetHeartRate() {
  129.  
  130. double maxthr1 = getMaximumHeartRate() * 0.85;
  131. return maxthr1;
  132. }
  133.  
  134. private double getMinimumTargetHeartRate () {
  135.  
  136. double minthr1 = getMaximumHeartRate() * 0.5;
  137. return minthr1;
  138. }
  139.  
  140. public void printInfo() {
  141. Object firstName = null;
  142. Object lastName = null;
  143. System.out.printf("FirstName: %s, %s\n", firstName, lastName);
  144. Date dob = null;
  145. System.out.printf("Date of birth: %d %s %d", dob.getDay(), dob.getMonth(), dob.getYear());
  146. String currentYear = null;
  147. System.out.printf("Current Year: " + currentYear);
  148. System.out.printf("\nYour age: %d%n", getAge());
  149. System.out.printf("Clinic analysis, based on your age: \n");
  150. System.out.printf(" 1. Your maximum heart rate is" + getMaximumHeartRate());
  151. System.out.printf(" 2. Your maximum target heart rate is" + getMaximumTargetHeartRate());
  152. System.out.printf(" 3. Your minimum target heart rate is" + getMinimumTargetHeartRate());
  153.  
  154. }
  155.  
  156. }
  157.  
  158.  
  159. private String getMinimumTargetHeartRate() {
  160. return null;
  161. }
  162. private Object getAge() {
  163. return null;
  164. }
  165.  
  166. private String getMaximumTargetHeartRate() {
  167. return null;
  168. }
  169.  
  170. private String getMaximumHeartRate() {
  171. return null;
  172. }
  173.  
  174. public static void main (String[] args) throws IOException {
  175.  
  176. Scanner input = new Scanner(new File("infile.txt"));
  177.  
  178. Date d = new Date ();
  179.  
  180.  
  181. String firstName, secondfirstName;
  182. String lastName, secondlastName;
  183. int currentYear, secondcurrentYear;
  184.  
  185. firstName = input.nextLine();
  186. lastName = input.nextLine();
  187. d.setDate (input.nextInt(), Month.valueOf (input.next()), input.nextInt());
  188. currentYear = input.nextInt();
  189.  
  190. HeartRates N = new HeartRates (firstName(), lastName(), dob(), currentYear());
  191. N.printInfo();
  192.  
  193. input.nextLine();
  194.  
  195. secondfirstName = input.nextLine();
  196. secondlastName = input.nextLine();
  197. Date d2 = new Date();
  198. d2.setDate (input.nextInt(), Month.valueOf (input.next()), input.nextInt());
  199. secondcurrentYear = input.nextInt();
  200.  
  201. HeartRates N2 = new HeartRates (secondfirstName, secondlastName, d2, secondcurrentYear);
  202.  
  203. N2.printInfo();
  204. }
  205. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement