Question: i need help in fixing my code. i'm using notepad++ import java.util.Scanner; import java.io.File; import java.nio.file.*;; //Enumeration to define the data type for Month enum

i need help in fixing my code. i'm using notepad++

import java.util.Scanner; import java.io.File; import java.nio.file.*;;

//Enumeration to define the data type for Month enum Month { Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec } // Declaring the instance variables for Date class as the date class class Date { //Defining the variable private int day; private Month month; private int year; //Assigning the start of each day, month, year //the default constructor is set to 1 of Jan 2021 public Date(){ this.day = 1; this.month = Month.Jan; this.year = 2021; } public Date(int day, Month month, int year) { this.day = day; this.month = month; this.year = year; } public Date(Date d) { this.day = d.day; this.month = d.month; this.year = d.year; } //Accessor methods public int getDay() { return day; } public Month getMonth() { return month; } public int getYear() { return year; } public void setDate(int day, Month month, int year) { this.day=day; this.month=month; this.year=year; } }

//Another class for HeartRates class HeartRates { //Defining the variable private String firstName; private String lastName; private Date dob; int currentYear; //Constructor public HeartRates(String firstName, String lastName, Date dob, int currentYear) { this.firstName = firstName; this.lastName = lastName; this.dob = dob; this.currentYear = currentYear; } public HeartRates(HeartRates hr){ this.firstName = hr.firstName; this.lastName = hr.lastName; this.dob = hr.dob; this.currentYear = hr.currentYear; } //Accessor methods public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } public Date getDob() { return dob; }

public void setDob(Date dob) { this.dob = dob; }

public int getCurrentYear() { return currentYear; } //Current year set 2021 - dob to return patientage public int getAge(){ int patientage=currentYear-dob.getYear(); return patientage; } public int getMaximumHeartRate(){ int MaxHeartRate=220-this.getAge(); return MaxHeartRate; } public double getMinimumTargetHeartRate(){ double getMinimumTargetHeartRate=this.getMaximumHeartRate()*50/100; return getMinimumTargetHeartRate; } public double getMaximumTargetHeartRate(){ double getMaximumTargetHeartRate=this.getMaximumHeartRate()*85/100; return getMaximumTargetHeartRate; } public void printInfo(){ System.out.printf("Name: "+this.firstName+", "+this.lastName); System.out.printf("Date of Birth: "+dob.getDay()+" "+dob.getMonth()+" "+dob.getYear()); System.out.printf("Current Year: "+currentYear); System.out.printf("Your age: "+this.getAge()+" years old"); System.out.printf("Clinic analysis, base on your age: %s%n", patientAge() ); System.out.printf("1. Your maximum heart rate is %s%n" , getMaximumHeartRate() ); System.out.printf("2. Your minimum target heart rate is %s%d", getMinimumTargetHeartRate () ); System.out.printf("3. Your maximum target heart rate is %s%d", getMaximumTargetHeartRate() ); } }

public class ReadTextAsString { public static String readFileAsString(String fileName)throws Exception { String firstName = input.nextLine(); String lastName = input.nextLine (); Date dob = input.nextLine(); int currentYear = input.nextInt(); } public static void main(String[] args) throws Exception { String data = readFileAsString("C:\\Users\\dessire\\PatientInfo.txt"); System.out.println(data); } }

i need help in fixing my code. i'm using notepad++ import java.util.Scanner;import java.io.File; import java.nio.file.*;; //Enumeration to define the data type for Month

enum Month { Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep,Oct, Nov, Dec } // Declaring the instance variables for Date class

Task (5 marks) While exercising, you can use a heart-rate monitor to see that your heart rate stays within range suggested by the trainers and doctors. The formula to calculate your maximum heart rate per minute is 220 (magic number) minus your age in years. Your target heart rate is a range that's 50 to 85% of your maximum heart rate. Let us explore the following UML diagram: cenumeration>> Month HeartRates Test A Jan A Feb Mar Apr May Jun Jul Aug Sep Oct + static void main(String args) Dec HeartRates month - String firstName - String lastName -Date dob -int currentYear Date -int day - Month month - int year 1_006 +Date +Date(int day, Month month, int year) +Date(Date d) +int getDayo + Month getMontho +int getYearo +void setDate(int day, Month month, int year) 4.1 +HeartRates(String firstName, String lastName, Date dob, int currentYear) + HeartRates(HeartRates hr) + String getFirstName +void setFirstName(String firstName) + String getLastName +void setLastName(String lastName) +Date getDOBO + void setDOB(Date dob) + int getCurrentYearo + void setCurrentYear(int currentYear) +int getAge +int getMaximum HeartRate + double getMinimumTargetHeartRate + double getMaximumTargetHeartRate +void printinfo Design 4 classes An enumeration Month class A Date class. Note that, other than the usual information for a calendar date (day, month, and year), you have constructors, accessor and mutator methods. For the default constructor, initialize the date to 1st January 2021. A HeartRate class has the same features as the Date class (constructors, accessor and mutator methods). You include also a few important methods related to the class; for example, get the maximum heart rate method, get the minimum and the maximum of the targeted heart rate; and a method to print out an object of this class. You construct a text file (using text editor, for example notepad) to store two persons' profiles. The sample format of this text file is: Ah Beng Tan 15 Oct 1988 2018 Robert Richard Wong 31 Dec 2005 2018 In the main method (defined in another class), try to read the information from the above text file and display the following output: Name: Ah Beng, Tan Date of birth: 15 Oct 1988 Current year: 2018 Your age: 30 years old Clinic analysis, base on your age: 1. Your maximum heart rate is 190 2. Your minimum target heart rate is 95.00 3. Your maximum target heart rate is 161.50 Name: Robert Richard, Wong Date of birth: 31 Dec 2005 Current year: 2018 Your age: 13 years old Clinic analysis, base on your age: 1. Your maximum heart rate is 207 2. Your minimum target heart rate is 103.50 3. Your maximum target heart rate is 175.95

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!