In this exercise, you’ll design a "starter" HealthProfile class for a person. The class attributes should include the person’s first name, last name, gender, date of birth (consisting of separate attributes for the month, day and year of birth), height (in inches) and weight (in pounds). Your class should have a constructor that receives this data. For each attribute, provide setters and getters.The class should include methods that calculate and return the user’s age in years, maximum heart rate and target heart rate range, and body mass index (BMI). Write a Java application that prompts for the person’s information, instantiates an object of class HealthProfile for that person and prints the information from that object—including the person’s first name, last name, gender, date of birth, height and weight—then calculates and prints the person’s age in years, BMI, maximum heart rate and target-heart-rate range. It should also display the BMI values chart.

Answers

Answer 1

Answer:

package healthcare;

import java.util.Calendar;

public class HealthProfile {

  private String firstName;

  private String lastName;

  private char gender;

  private int day;

  private int month;

  private int year;

  private double height;

  private double weight;

  public HealthProfile(String firstName, String lastName, char gender, int day, int month, int year, double height,

          double weight) {

      super();

      this.firstName = firstName;

      this.lastName = lastName;

      this.gender = gender;

      this.day = day;

      this.month = month;

      this.year = year;

      this.height = height;

      this.weight = weight;

  }

  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 char getGender() {

      return gender;

  }

  public void setGender(char gender) {

      this.gender = gender;

  }

  public int getDay() {

      return day;

  }

  public void setDay(int day) {

      this.day = day;

  }

  public int getMonth() {

      return month;

  }

  public void setMonth(int month) {

      this.month = month;

  }

  public int getYear() {

      return year;

  }

  public void setYear(int year) {

      this.year = year;

  }

  public double getHeight() {

      return height;

  }

  public void setHeight(double height) {

      this.height = height;

  }

  public double getWeight() {

      return weight;

  }

  public void setWeight(double weight) {

      this.weight = weight;

  }

  public int calculateAge() {

       

      Calendar dateOfBirth = Calendar.getInstance();

      dateOfBirth.set(year, month, day);

      Calendar now = Calendar.getInstance();

      return now.get(Calendar.YEAR) - dateOfBirth.get(Calendar.YEAR);

  }

  public int maximumHeartRate() {

      return 220 - calculateAge();

  }

  public double[] targetHeartRateRange() {

      double[] range = new double[2];

      // Calculate Stating range(50 % of maximumHeartRate)

      range[0] = 0.5 * maximumHeartRate();

      // Calculate End range(85 % of maximumHeartRate)

      range[1] = 0.85 * maximumHeartRate();

      return range;

  }

  public double calculateBMI() {

      return (weight * 703)/(height * height);

  }

  public String getBMIValue()

  {

      double bmi=calculateBMI();

      if(bmi < 18.5)

      {

          return "Underweight";

      }

      else if (bmi>18.5 && bmi<24.9)

      {

          return "Normal";

      }

      else if (bmi>25 && bmi<29.9)

      {

          return "Normal";

      }

      else if (bmi>=30)

      {

          return "Obese";

      }

      return "DafultValue"; //you can give any default value of your choice here if no condition meets the given criteria

  }

  @Override

  public String toString() {

      return "HealthProfile [firstName=" + firstName + ", lastName=" + lastName + ", gender=" + gender + ", Date Of Birth="

              + day + "-" + month + "-" + year + ", height=" + height + ", weight=" + weight + "]";

  }

}

package healthcare;

import java.util.Scanner;

public class TestHealthCare {

  private static Scanner sc;

  public static void main(String[] args) {

      sc = new Scanner(System.in);

      System.out.println("Please enter following details of the Patient");

      System.out.println("First Name");

      String firstName=sc.nextLine();

      System.out.println("Last Name");

      String lastName=sc.nextLine();

      System.out.println("Gender ...... M or F ?");

      char gender=sc.next().charAt(0);

      System.out.println("Date of Birth");

      System.out.println("Day");

      int day=sc.nextInt();

      System.out.println("Month");

      int month=sc.nextInt();

      System.out.println("Year");

      int year=sc.nextInt();

      System.out.println("Height in inches");

      double height =sc.nextDouble();

      System.out.println("weight (in pounds)");

      double weight =sc.nextDouble();

     

      HealthProfile obj=new HealthProfile(firstName, lastName, gender, day, month, year, height, weight);

      int age=obj.calculateAge();

      System.out.println("Patient age is   "+age + " Years");

     

      int maxHeartRate=obj.maximumHeartRate();

      System.out.println("Patient Maximum Heart Rate is   "+maxHeartRate + " beats per minute");

     

      //Call targetHeartRateRange

      double targetHeartRateRange []=obj.targetHeartRateRange();

      System.out.println("Target Heart Range is   "+targetHeartRateRange [0] + " - " +targetHeartRateRange [1]);

     

      //Call calculateBMI

      double bmi=obj.calculateBMI();

      System.out.println("Patient BMI is   "+bmi);

     

      //call getBMIValue

      System.out.println("Patient BMI Value is   "+obj.getBMIValue());

  }

}

Explanation:

Inside the calculate the age in years  method, create Date of Birth of Object.Create Current Date .Inside the method maximumHeartRate , create a New Object of HealthProfile class and Call its constructor .

Related Questions

Explain how increasingly standardized data, access to third-party datasets, and current trends in hardware and software are collectively enabling a new age of decision making?

Answers

Answer and Explanation:

The information revolution has had profound impacts on decision-making allowing more informed decision as a result of "stone throw" information reach- in our pockets, the desk, the TV, and the vast number of technologies that make this possible.

Standardized data which involves data formatted to bring uniformity and be easily understood and compared by programs and people , access to rich, outsider dataset and less tasking and flexible plus powerful programming have all contributed to empowering another time of information driven decision-making that are less prone to errors and mistakes.

Advances in data storage techniques and the rapidly declining costs of data storage threaten​ ________. A. organizational procedures B. individual privacy C. growth in mobile devices D. network advances E. analytical procedures

Answers

Answer:

Option C is the correct option.

Explanation:

In the above scenario, Advancements in storage technologies and fast-declining storage prices are undermining growth in the mobile device because current mobile devices have many useful features of data storage and it can also use in other fields such as cloud storage, also in word processing and many other areas which are useful for the users.

Option A is incorrect because it is not suitable according to the following case. Option B is incorrect because data storage is not related the individual privacy. Options D and E are incorrect because in the above case, it is about the data storage techniques not for the network advances and analytical procedures.
Other Questions
Find the area of the figure.triangle with base 27.5 m and height 4.8 m Unfortunately, Tori doesn't have enough money in her account right now. She needs to make additional contributions at the end of each of the next five years to be able to pay for the repairs. Her account currently has $3,500, which, along with her additional contributions, is expected to continue earning 8% annual interest. If she makes equal contributions each year, how large must each contribution be for Tori to have $8,000 after five years? The stock of Company A gained 4% today to $47.84. What was the opening price of the stock in the beginning of the day? a recycling plant processes an average of 1/3 ton of glass each minute.At approximately what rate does the recycling plant process glass,in tons per day? Which of the following ethical theories is adopted by a company that strives to act as ethically as possible, even at the expense of some additional profits, as long as the business remains profitable?a. The maximizing profits theory b. The invisible hand theory c. The moral minimum theory d. The competitive advantage theory Define tissue with regards to anatomy *A group of structurally and functionally related cells that come together to performcommon functionsOA series of different cells in the same areaOMultiple sheets of thin paper used to clean your noseOThe smallest structural and functional unit of an organism colonial familesA. Produced most of what they neededB. Mostly Worked in factoriesC. Produced little of what they neededD. Usually only had one child In 1906, Harden and Young, in a series of classic studies on the fermentation of glucose to ethanol and CO 2 by extracts of brewer's yeast, made the observations inorganic phosphate was essential to fermentation; when the supply of phosphate was exhausted, fermentation ceased before all the glucose was used; during fermentation under these conditions, ethanol, CO 2 , and a sugar phosphate accumulated; when arsenate was substituted for phosphate, no sugar phosphate accumulated, but the fermentation proceeded until all the glucose was converted to ethanol and CO 2 . Which enzyme of glycolysis requires inorganic phosphate and, therefore, stops when no phosphate is available what mineral property is illustrated by this photograph? If the circumference of each tire on a vehicle is approximately 88 in., how many miles will the vehicle travel when the tires make 2323,000 revolutions? ANSWER ASAP REALLY NEED IT RN 2. What can you conclude about two triangles when you know that two pairs ofcorresponding sides and the corresponding included angles are congruent? PLEASEEEEE HELP ASAP!!! Jeannie needs 2 cups of milk to make her homemade brownies. How many fluid ounces does Jeannie need? Dr. Rip Van Winkle is requesting permission to do a sleep deprivation study involving young children. He has hypothesized that children between the ages of five and seven need uninterrupted sleep to do well with basic memory functions.He has proposed a study where children in this age category will be awakened each hour during one night in his laboratory, and then tested on basic memory abilities.These results will then be compared with those obtained after a normal night of sleep.He is offering parents a $250 incentive if they will agree to allow their children to participate in this study.The children will be given a gift certificate to a local toy store for their participation.Should this study be approved? What concerns do you have? What is the degree of the polynomial below?2^2 + 3x +1 A sine function has the following key features: Frequency = 1/4 Amplitude = 2 Midline: y = 2 y-intercept: (0,2) The function is not a reflection of its parent function over the x-axis. Use the sine tool to graph the function. The first point must be on the midline and the second point must be a maximum or minimum value on the graph closest to the first point. Michael Company reports the following account balances at the end of the first year of operations: Revenues $ 160 comma 000 Cost of Goods Sold $ 46 comma 000 Salaries Expense $ 21 comma 000 Dividends Declared and Paid $12,000 Utilities Expense $ 11 comma 000 Advertising Expense $10,000 Short-term Investments $ 14 comma 000 Cash $ 102 comma 000 Land $ 40 comma 000 Common Stock $50,000 What are total liabilities at the end of the first year? Cole has a cold. Although the brand-name drug is more expensive than the generic, he buys the brand-name one. Cole is familiar with the brand-name drug and knows exactly what to expect whe A good claim provides a focused, structured direction foryour paragraph.Write a claim that summarizes why your chosen issue isimportant to your community.Describe your claim in at least two sentences.